Re: Problem with year dropdown

2014-01-30 Thread Sam Clauw
Allright, thank you very much, that's the dropdown I was looking for!

-- 
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+unsubscr...@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.


Re: Problem with year dropdown

2014-01-28 Thread Sam Clauw
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...?

-- 
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+unsubscr...@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.


Re: Problem with year dropdown

2014-01-28 Thread AD7six


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+unsubscr...@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.


Problem with year dropdown

2014-01-23 Thread Sam Clauw
Hi guys!

I have a dropdown where you can choose an opening year of a themepark 
attraction.

Database

Column: opened
Type: year(4)
Null: no
Standard value: none

So far so good. Now I try to display a dropdown with year values between 
1954 (opening park) and the current year + 1.

edit.ctp

echo $this-Form-inputs(array(
'legend' = false,
'name' = array(
'label' = 'Name'
),
*'opened' = array(*
*'type' = 'year',*
*'label' = 'Year opening',*
*'dateFormat' = 'Y',*
*'minYear' = 1954,*
*'maxYear' = date('Y') + 1,*
*'empty' = 'Kies...'*
*),*
'show' = array(
'type' = 'radio',
'legend' = 'Show on website',
'options' = array(
'Y' = 'Ja',
'N' = 'Nee'
)
)
));

But here comes my first problem. The dropdown output is a list with values 
from 2034 to 0 and that's not the kind of options I want. When I change the 
type to date, the options do work great then. BUT then the selected value 
on edit is always 1970 (database says 1984). What could be the problem 
here?

My second problem occurs when saving the changes. Everytime I do so, I've 
got the error:

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Array' in 
 'field list'


I've debugged the request object and saw the following:

object(CakeRequest) {
params = array(
'plugin' = 'coaster_cms',
'controller' = 'attractions',
'action' = 'edit',
'named' = array(),
'pass' = array(
(int) 0 = '1'
)
)
data = array(
'Attraction' = array(
'name' = 'Boomerang',
'opened' = array(
'year' = '1984'
),
'show' = 'Y'
)
)
}

As you can see, the opened value send to the request object is an array. 
How can I change it so the data array have something like 'opened' = 1984 
in it?

Thanks for helping me ;)

-- 
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+unsubscr...@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.