Saturday, July 27, 2013

Saving datetime

How can i save an array like:

array(
'OnOff' => array(
'module_id' => '23',
'date_start' => array(
'month' => '07',
'day' => '28',
'year' => '2013',
'hour' => '01',
'min' => '40',
'meridian' => 'am'
),
'date_end' => array(
'month' => '07',
'day' => '28',
'year' => '2013',
'hour' => '01',
'min' => '40',
'meridian' => 'am'
),
'minutes_on' => '100',
'minutes_off' => '100'
)
)

Validation is:

public $validate = array(
        'date_start' => array(
            'rule' => array('datetime', 'mdy'),
            'required' => true,
            'allowEmpty' => false,
            'message' => 'Please enter a valid date and time.'
        ),
        'date_end' => array(
            'rule' => array('datetime', 'mdy'),
            'required' => true,
            'allowEmpty' => false,
            'message' => 'Please enter a valid date and time.'
        ),
        'minutes_on' => array(
            'rule' => 'numeric',
            'required' => true,
            'allowEmpty' => false,
            'message' => 'Numbers only'
        ),
        'minutes_off' => array(
            'rule' => 'numeric',
            'required' => true,
            'allowEmpty' => false,
            'message' => 'Numbers only'
        )
    );

And always fail with 'Please enter a valid date and time.'

--
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: