Wednesday, October 3, 2012

html attributes on 'year' form helper

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 cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.

No comments: