Search code examples
cakephp-2.0form-helpers

Cakephp Year format


I am using form helper in Cakephp 2.x

<?php echo $this->Form->year('Album.year', 1950, date('Y'), array('type' => 'select', 'label' => false, 'div' => false, 'class' => "textbox", 'empty' => 'Select Year')); ?>

This code outputs

<select id="AlbumYearYear" class="textbox" name="data[Album][year][year]">
    <option value="">Select Year</option>
</select>

In this way . while other fields are outputting as name="data[Model][source_id]". Like this

How would I remove second [year] in above mentioned element because its causing error in saving $this-request->data as year is array element.


Solution

  • instead of doing

    $this->Form->year('Album.year'

    do

    $this->Form->year('Album'