It seems that the year helper doesn't support html attributes. Looking
at the API (http://api.cakephp.org/class/form-helper#method-FormHelperyear),
it only accepts a small subset of the options that other form helper
functions support. I guess this is because it returns a SELECT element
and they normally join in with other elements.

It looks like you will have to manually add the div and label around
the year helper.

Mike.

On Thu, Oct 4, 2012 at 12:06 AM, Paul Willis <[email protected]> wrote:
> Despite having read over the relevant sections of the book I can't seem to 
> get the <div> stuff working properly with $this->Form->year form helper in 
> 2.2.2
>
> Any other standard input select like...
>
> echo $this->Form->input(
>         'category', array(
>                 'type' => 'select',
>                 'options' => $category,
>         )
> );
>
>
> Produces HTML like this...
>
> <div class="input select">
>         <label for="ReportCategory">Category</label>
>         <select name="data[Report][category]" id="ReportCategory">
>                 <option value="1">Category1</option>
>                 <option value="2">Category2</option>
>         </select>
> </div>
>
> I want to do the same with a 'year' select but the standard tag...
>
> echo $this->Form->year(
>         'published', 1990, date('Y'), array(
>                 'empty' => false,
>         )
> );
>
> …produces HTML without a label or div…
>
> <select name="data[Report][published][year]" id="ReportPublishedYear">
>         <option value="2012">2012</option>
>         <option value="2011">2011</option>
>         <option value="2010">2010</option>
>         …etc…
>         <option value="1990">1990</option>
> </select>
>
> I've tried (along with other variations)...
>
> echo $this->Form->year(
>         'published', 1990, date('Y'), array(
>                 'empty' => false,
>                 'label' => 'Published',
>                 'div' => array(
>                         'class' => 'input select',
>                         'id' => 'published',
>                 )
>         )
> );
>
>
> But I get a weird result…
>
> <select name="data[Report][published][year]" label="Published" id="published" 
> div="input select">
>         <option value="2012">2012</option>
>         <option value="2011">2011</option>
>         <option value="2010">2010</option>
>         …etc…
>         <option value="1990">1990</option>
> </select>
>
>  I'm assuming I'm just getting the syntax messed up but can the 'year' form 
> helper accept html attributes? Anyone see what I'm doing wrong here?
>
> Cheers
>
> Paul
>
> --
> Like Us on FacekBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

-- 
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to