Hi Thomas,

I don't know in what order dirs are looked up for helpers, but after
what you said, I would assume the helpers directory from the core is
looked at first. However I ran into the same problem, the html helper
had a few things I wanted to improve and so what I did is creating my
own html helper;

I still didn't figure out how to 'extend' a helper... but I hope this
will help;

First I created a file called eo_html.php in my application helpers
dir. it looks like this; (partial)

<code>
<?php
class eoHtmlHelper extends Helper {
        var $helpers = array('Html');
}
?>
</code>

the var $helpers = array('Html'); line ensures I'll be able to call the
html helper when needed.

Then I whenever I run into something in the html helper that makes no
sense in my app, I 'override' (sort of). For instance the
html->selectTag will not select the default value (from the object)
unless $selected is specified... so instead of modifying the
htmlhelper, I added the following to my helper;

<code>
function selectTag($fieldName, $optionElements, $selected = null,
$selectAttr = array(), $optionAttr = null, $showEmpty = true, $return =
false) {
    if (!$selected) $selected = $this->Html->tagValue($fieldName);
    return $this->Html->setFormTag($fieldName, $optionElements,
$selected, $selectAttr, $optionAttr, $showEmpty, $return);
}
</code>

notice how I call the original html helper with '$this->Html->...'

Finally, in my view, instead of going $html->selectTag, I use
$eoHtml->selectTag, of course after I added eoHtml to my $helpers array
in my controller!

I cannot say that's the best solution ever (and would appreciate any
comment in re to that!), but so far it's worked quite well!

Hope this helps!

Seb.


On Dec 5, 5:47 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi all,
>
> I want to have a custom HTML Helper in my helpers dir and it seems like
> it's always the one belonging to the core that is used, it doesn't seem
> to be the same with the form helper for instance.
>
> any idea what i' doing wrong ?
> 
> is it an intended behaviour ?
> 
> tia
> 
> thomas


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to