CJuiDatePicker not working within CActiveForm

Following code is not showing the datepicker…




$form = $this->beginWidget('CActiveForm', array(

	'id'=>'pm-report-form',

	'enableAjaxValidation'=>false,

        'htmlOptions'=>array(

            'autocomplete'=>'off',

        ),

));


print "<p'><b>Date:&nbsp;</b>";

$this->widget('zii.widgets.jui.CJuiDatePicker', array(

    'model'=>$reportModel,

    'attribute'=>'pm_date',

    'value' => $reportModel->pm_date,

    'options'=>array(

        'dateFormat'=>'dd/mm/yy',

    ), 

));

print "</p>";

$this->endWidget();



Whereas if a change the code without model and attribute as follows, it displays the datepicker properly.




$form = $this->beginWidget('CActiveForm', array(

	'id'=>'pm-report-form',

	'enableAjaxValidation'=>false,

        'htmlOptions'=>array(

            'autocomplete'=>'off',

        ),

));


print "<p'><b>Date:&nbsp;</b>";

$this->widget('zii.widgets.jui.CJuiDatePicker', array(

    'name' =>  'datefield',

    'options'=>array(

        'dateFormat'=>'dd/mm/yy',

    ),  

    ));

print "</p>";

$this->endWidget();



can you comment out the value line and try without it

Still not working…




$this->widget('zii.widgets.jui.CJuiDatePicker', array(

    'model'=>$reportModel,

    'attribute'=>'pm_date',

    //'value' => $reportModel->pm_date,

    'options'=>array(

        'dateFormat'=>'dd/mm/yy',

    ), 

));



can you try to debug in firebug

also can you double check your $reportModel

Firebug is not reporting any error!!!

Dump of $reportModel. Seems ok.





object(RptAmfPanel)#61 (12) { ["_md":"CActiveRecord":private]=> object(CActiveRecordMetaData)#50 (5) { ["tableSchema"]=> object(CMysqlTableSchema)#52 (9) { ["schemaName"]=> NULL ["name"]=> string(13) "rpt_amf_panel" ["rawName"]=> string(15) "`rpt_amf_panel`" ["primaryKey"]=> string(17) "rpt_amf_panel_uid" ["sequenceName"]=> string(0) "" ["foreignKeys"]=> array(0) { } ["columns"]=> array(6) { ["rpt_amf_panel_uid"]=> object(CMysqlColumnSchema)#53 (14) { ["name"]=> string(17) "rpt_amf_panel_uid" ["rawName"]=> string(19) "`rpt_amf_panel_uid`" ["allowNull"]=> bool(false) ["dbType"]=> string(7) "int(11)" ["type"]=> string(7) "integer" ["defaultValue"]=> NULL ["size"]=> int(11) ["precision"]=> int(11) ["scale"]=> NULL ["isPrimaryKey"]=> bool(true) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(true) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["sys_report_id"]=> object(CMysqlColumnSchema)#54 (14) { ["name"]=> string(13) "sys_report_id" ["rawName"]=> string(15) "`sys_report_id`" ["allowNull"]=> bool(false) ["dbType"]=> string(7) "int(11)" ["type"]=> string(7) "integer" ["defaultValue"]=> NULL ["size"]=> int(11) ["precision"]=> int(11) ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["pm_date"]=> object(CMysqlColumnSchema)#55 (14) { ["name"]=> string(7) "pm_date" ["rawName"]=> string(9) "`pm_date`" ["allowNull"]=> bool(true) ["dbType"]=> string(4) "date" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> NULL ["precision"]=> NULL ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["dg_no"]=> object(CMysqlColumnSchema)#56 (14) { ["name"]=> string(5) "dg_no" ["rawName"]=> string(7) "`dg_no`" ["allowNull"]=> bool(true) ["dbType"]=> string(11) "varchar(45)" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> int(45) ["precision"]=> int(45) ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["ovr_curr_relay_set"]=> object(CMysqlColumnSchema)#57 (14) { ["name"]=> string(18) "ovr_curr_relay_set" ["rawName"]=> string(20) "`ovr_curr_relay_set`" ["allowNull"]=> bool(true) ["dbType"]=> string(11) "varchar(45)" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> int(45) ["precision"]=> int(45) ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["erth_flt_relay_set"]=> object(CMysqlColumnSchema)#58 (14) { ["name"]=> string(18) "erth_flt_relay_set" ["rawName"]=> string(20) "`erth_flt_relay_set`" ["allowNull"]=> bool(true) ["dbType"]=> string(11) "varchar(45)" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> int(45) ["precision"]=> int(45) ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } } ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["columns"]=> array(6) { ["rpt_amf_panel_uid"]=> object(CMysqlColumnSchema)#53 (14) { ["name"]=> string(17) "rpt_amf_panel_uid" ["rawName"]=> string(19) "`rpt_amf_panel_uid`" ["allowNull"]=> bool(false) ["dbType"]=> string(7) "int(11)" ["type"]=> string(7) "integer" ["defaultValue"]=> NULL ["size"]=> int(11) ["precision"]=> int(11) ["scale"]=> NULL ["isPrimaryKey"]=> bool(true) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(true) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["sys_report_id"]=> object(CMysqlColumnSchema)#54 (14) { ["name"]=> string(13) "sys_report_id" ["rawName"]=> string(15) "`sys_report_id`" ["allowNull"]=> bool(false) ["dbType"]=> string(7) "int(11)" ["type"]=> string(7) "integer" ["defaultValue"]=> NULL ["size"]=> int(11) ["precision"]=> int(11) ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["pm_date"]=> object(CMysqlColumnSchema)#55 (14) { ["name"]=> string(7) "pm_date" ["rawName"]=> string(9) "`pm_date`" ["allowNull"]=> bool(true) ["dbType"]=> string(4) "date" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> NULL ["precision"]=> NULL ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["dg_no"]=> object(CMysqlColumnSchema)#56 (14) { ["name"]=> string(5) "dg_no" ["rawName"]=> string(7) "`dg_no`" ["allowNull"]=> bool(true) ["dbType"]=> string(11) "varchar(45)" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> int(45) ["precision"]=> int(45) ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["ovr_curr_relay_set"]=> object(CMysqlColumnSchema)#57 (14) { ["name"]=> string(18) "ovr_curr_relay_set" ["rawName"]=> string(20) "`ovr_curr_relay_set`" ["allowNull"]=> bool(true) ["dbType"]=> string(11) "varchar(45)" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> int(45) ["precision"]=> int(45) ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } ["erth_flt_relay_set"]=> object(CMysqlColumnSchema)#58 (14) { ["name"]=> string(18) "erth_flt_relay_set" ["rawName"]=> string(20) "`erth_flt_relay_set`" ["allowNull"]=> bool(true) ["dbType"]=> string(11) "varchar(45)" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> int(45) ["precision"]=> int(45) ["scale"]=> NULL ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["autoIncrement"]=> bool(false) ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } } ["relations"]=> array(0) { } ["attributeDefaults"]=> array(0) { } ["_model":"CActiveRecordMetaData":private]=> object(RptAmfPanel)#49 (12) { ["_md":"CActiveRecord":private]=> *RECURSION* ["_new":"CActiveRecord":private]=> bool(false) ["_attributes":"CActiveRecord":private]=> array(0) { } ["_related":"CActiveRecord":private]=> array(0) { } ["_c":"CActiveRecord":private]=> NULL ["_pk":"CActiveRecord":private]=> NULL ["_alias":"CActiveRecord":private]=> string(1) "t" ["_errors":"CModel":private]=> array(0) { } ["_validators":"CModel":private]=> NULL ["_scenario":"CModel":private]=> string(0) "" ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } } ["_new":"CActiveRecord":private]=> bool(false) ["_attributes":"CActiveRecord":private]=> array(6) { ["rpt_amf_panel_uid"]=> string(1) "3" ["sys_report_id"]=> string(1) "3" ["pm_date"]=> NULL ["dg_no"]=> NULL ["ovr_curr_relay_set"]=> string(6) "fghgfh" ["erth_flt_relay_set"]=> NULL } ["_related":"CActiveRecord":private]=> array(0) { } ["_c":"CActiveRecord":private]=> NULL ["_pk":"CActiveRecord":private]=> string(1) "3" ["_alias":"CActiveRecord":private]=> string(1) "t" ["_errors":"CModel":private]=> array(0) { } ["_validators":"CModel":private]=> NULL ["_scenario":"CModel":private]=> string(6) "update" ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } RptAmfPanel[pm_date]




can you add the value line to the working scenario and see if it is still working. I cannot see anything wrong in your datepicker setup

value is working … but presently value is NULL… is it a problem.