Suppose you want to override FormHelper::error() on a sitewide level.
You don't want to change anything else, just FormHelper::error().
You've already written the views using FormHelper, and you need to
extend it.
Currently you'd have to reference your form helper (call it
'MyFormHelper' for example) in the view as $myForm->blabla(), after
specifying that you need the helper in the controller, which means
replacing every call to $form->xyz() with $myForm->xyz(), in every
view file.
The point isn't to confuse anyone, it's just to make it simpler for
yourself. You're creating a form, you want to call $form->whatever(),
whether you've changed things or not. Of course, if you get override
the methods to do something completely different then it might get
confusing (and provoke hair loss!), but if you keep things consistent,
I don't think it would be a problem.
Of course, the same would apply to other helpers - want to add a
currency format to NumberHelper::currency(), or set the default
format? You're not changing what the NumberHelper really is, you're
just specialising it for your needs.
Still, it's just an idea. Your view does make sense, it could be
confusing if a lot of changes were made...
On Feb 5, 4:06 pm, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote:
> I don't think this is a very good idea.
>
> I mean, a HtmlHelper is a HtmlHelper. If you modify it, it becomes
> "ProfireHtmlHelper" and it is no longer supposed to be "HtmlHelper".
> And if someone else tries to use it now knowing it's not the same
> anymore, there might be hair loss. I'd go with AdvancedHtmlHelper or
> ExtendedAjaxHelper or whatever; what is the point of "reusing" the
> same name with a different class?? To confuse someone?
>
> That's just my 2c.
>
> On Feb 5, 4:50 pm, grigri <[EMAIL PROTECTED]> wrote:
>
> > While it's true that submissions to trac *do* help extend the
> > functionality of the core code, I do see ProFire's point.
>
> > There is no way that a helper can perform everything that you'd want,
> > even if it was totally bloated with code. It would be nice to be able
> > to extend the core helpers without replacing them entirely, but also
> > without changing the name.
>
> > One possible way would be helper aliases. For example, in your
> > controller you could do:
>
> > var $helpers = array('Html' => 'MyHtml');
>
> > which would load the 'MyHtml' helper but alias it as Html. Assuming
> > your MyHtmlHelper extends HtmlHelper, this would work smoothly. You
> > could just override the methods you need, and bob's your uncle.
>
> > One problem with this would be keeping track of the whole helper chain
> > - for example if you've aliased MyHtml to Html, and another helper
> > (Ajax?) uses the HtmlHelper, which one does it load? The original or
> > the overloaded one?
>
> > What are your thoughts on this? Does anyone else think this is a good
> > idea?
>
> > On Feb 5, 2:56 pm, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote:
>
> > > Why not submit your modification to trac, perhaps it's good enough to
> > > be accepted!
>
> > > On Feb 5, 1:22 pm, ProFire <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Bakers!
>
> > > > Been using CakePHP for some time already and I'm getting the hang of
> > > > it. I'm loving it too.
>
> > > > However, as CakePHP is still young, I noticed a few missing features.
> > > > More specifically, AjaxHelper! I have modified the core file,
> > > > ajax.php. So far it works fine for now.
>
> > > > I would like to ask, is there a way to modify/extend the features of
> > > > the core helpers without modifying the core files? The way I know of
> > > > is to create an entirely different helper, but I won't be able to
> > > > reuse the name.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---