KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My Goal: Replace the Default Cake Datepicker I hate the default CakePHP FormHelper date-picker select elements and I'd like to use jQuery UI Datepicker widget instead. In order to degrade gracefully, I want to have a date field (enabled with the widget) and a time-picker select box constrained to 15-minute increments. In case I explained that poorly, here is what it looks like: My Ideal Solution To minimize repetition, I want to put the HTML in a layout Element and process it using a Behavior function. This way I could do something like the following: view.ctp echo $this->element( 'datepicker', array( 'data' => $data ) ); model.php $actsAs = array( 'Datepicker' ); function beforeSave( $options ){ $this->parseDatepickers(); //behavior function would alter $this->data return true; } The Problem Unfortunately, by the time it gets to the beforeSave (or beforeValidate ) callback, the datepicker & timepicker fields have been destroyed by the model's deconstruct function. deconstruct seems to be looking for dates & times to be reported the way FormHelper creates them. In short, it's looking for: [date_field] => Array ( [year] => 2011 [month] => 11 [day] => 11 [hour] => 8 [min] => 00 [meridian] => pm ) but instead it's finding: [date_field] => Array ( [datepicker] => 11/11/2011 [timepicker] => 8:00 pm ) And because it doesn't find the structure it expects, I end up with this: [date_field] => I know I can have jQuery update hidden inputs with the appropriately-named fields, but this woul
Tags (comma-separated)
Save Edits
Cancel