简体   繁体   中英

CakePHP 2.x form helper date not showing

I try to use the CakePHP Form Helper to create a DMY select:

echo $this->Form->create('ReportCleaner');
echo $this->Form->input('repday', array('dateFormat' => 'DMY', 'minYear' => date('Y'),
                                             'maxYear' => date('Y') + 1, 'label' => 'Date','value'=>'1987-02-12','empty'=>false));
echo $this->Form->end(__('Submit')); 

But it's showing me only a simple input field.

UPDATE AFTER PROBLEM SOLVED:

echo $this->Form->input('repday', array('dateFormat' => 'DMY', 'minYear' => date('Y'),
                                             'maxYear' => date('Y') + 1, 'label' => 'Date','empty'=>false, 'type'=>'date'));

Problem was that this field was coming from different model and not recognized as date. the type option fixed it. Thanks.

如果未在模型中检测到您的字段或将其设置为一个字段,则需要type="date"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM