php - CJuiDatePicker Always saves present day in database -


My code in this model rules is ................ .................................................. .................................................. .........

  array ('dataMedicao', 'type', 'type' = & gt; 'date', 'message' = & gt; 'attribute }: New CDBXpress ('now'): 'Date' is not a date! ',' DateFormat '=>' yyyy-MM-dd '), array (' datamdicio ',' default ',' value '=> ), // Automatically add current date to mysql feild 'setOnEmpty' = & gt; right, '' = 'gt;' update '), array (' date_created, date_modified ',' default ',' value '=' & Gt; New CDBI Express ('now ()'), 'SetOnEmpty '= & Gt; False, but' = ';' Insert '),  

............... ...... .................................................. ...... .................................................. ...... ....

Saved Functions from Save (First) {$ this- & gt; DataMedicio = new CDBI Express ('now ()'); Return Parent: First Save (); } After the secure function () {$ this-> DataMedico = Date ('Y-M-D', Straighttoem ($ -> - DataMedicocio)); Return TRUE; }

...................................... .................................................. ...................................

This form has my code in it .. .

  & lt ;? Php echo $ form- & gt; Labelex ($ model, 'datamadicio'); ? & Gt; & Lt ;? Php $ this- & gt; Widgets ('zii.widgets.jui.CJuiDatePicker', Array ('name' = & gt; 'datamatoco', 'attribute' = & gt; 'datamedia', 'value' => model- & gt; datamedia, // Additional JavaScript option for the date picker plugin 'Options' = & gt; array (' showname '= & gt;' guna ',' date format '=>,' yy-mm-dd ',),' html Option '= & gt; array (' style '= & gt;' height: 20px; '),)); ? & Gt; & Lt ;? Php Acor $ form- & gt; Error ($ Model, 'DataMedico'); ? & Gt;  

....................................... .................................................. ..................................

0000- 00-00 in my DB dates And when I list them, they are set up to 19 01-01-01 ... then on updates I use Detector to set the date for updating the field, but it is always the current date Updates on what we are on .. I set what date in DatePicker and how can I save it in my DB The front?! Thanks for all help

Your first save ensures that < Code> $ this - & gt; DataMedica is always set to NOW () whenever the record is updated, remove this line or wrap it in a condition such that it is only if it is inserted. Secure function $ - this-> dataMedicao = new CDBI Express ('now ()') before

  save () (if ($ -> this new - new record);); Return parent: First Save ();}  

This can also be done by editing your rules .

Also add your datepicker Code should refer to the $ model as follows:

  $ this-> widget ('zii.widgets.jui.CJuiDatePicker', array (' Model '= & gt; $ model,' attribute '= & gt; without it,  dataMedicao  is largely assigned Can not be set during the statement because the  name of the post variable is   datamodica  and   [datamdica] . 


Comments