php - set value yiibooster datePickerGroup -
my code:
<?php echo $form->datepickergroup( $model, 'to_date', array( 'widgetoptions' => array( 'options' => array( 'language' => 'en', 'format' => 'yyyy-mm-dd', ), ), 'wrapperhtmloptions' => array( 'class' => 'col-sm-5', ), 'hint' => 'click inside! super cool date field.', 'prepend' => '<i class="glyphicon glyphicon-calendar"></i>' ) ); ?>
my to_date timestamp want befor view value convert value by: date("y-m-d",$model->to_date)
accessor methods in model can serve well. if yii1 see accessor methods in model class, call accessors instead of returning property directly.
define getter , setter methods in model , convert timestamp \date(which needed cgridview) , vice-versa. like:
// in model class instantiated $model /** * @return \datetime */ public function getto_date(){ $date = new datetime(); $date->settimestamp($this->to_date); return $date; } /** * @param \datetime $to_date * @return $this */ public function setto_date(\datetime $to_date){ $this->to_date = strtotime($to_date); return $this; }
the rest of code cgridview remain intact , can use is.
Comments
Post a Comment