Tuesday, January 28, 2014

Re: Problem with year dropdown



On Tuesday, 28 January 2014 14:43:50 UTC+1, Sam Clauw wrote:
Is there nobody who can help me with this? Could it be possibile dat the datebase field type "year" isn't supported in CakePHP? If yes, what should I use instead? Varchar or...?

 'type' => 'year',

A year input is intended to be used as part of a date - it doesn't work on it's own. If you check the html source your data will be ala:

<select name="data[Foo][opened][year]">

and not

<select name="data[Foo][opened]">

Instead of using `year` - I suggest to use a select (which is all the year input is) like so:

    $years = range(1954, date('Y') + 1);
    $years = array_combine($years, $years);

    'opened' => array(
        'label' => 'Year opening',
        'options' => $years,
        'empty' => 'Kies...'
    ),

AD

--
Like Us on FaceBook 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: