Extend the helper this way:

1. Create a file called myhtml.php on your app/views/helpers directory.

2. Have its contents be something like the following. I'm overriding method
selectTag as in your example, with some small changes, like... PLEASE USE
BRACES! :)

<?php

loadHelper('html');

class MyhtmlHelper extends HtmlHelper 
{
        function selectTag($fieldName, $optionElements, $selected = null,
$selectAttr = array(), $optionAttr = null, $showEmpty = true, $return =
false) 
        {
                if (!$selected)
                {
                        $selected = parent::tagValue($fieldName);
                }

                return parent::setFormTag($fieldName, $optionElements,
$selected, $selectAttr, $optionAttr, $showEmpty, $return);
        }
}

?>

So you see whenever you need to call cake's html helper you just do
parent::method()

3. Then on your controllers add the helper:

var $helpers = array ( 'Myhtml' );

4. And use it on your views:

$myhtml->selectTag(...)

-MI

---------------------------------------------------------------------------

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!


-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de Ryders
Enviado el: Lunes, 04 de Diciembre de 2006 06:35 p.m.
Para: Cake PHP
Asunto: Re: custom html helper

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


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