LoginSignup
0
0

More than 5 years have passed since last update.

CakePHP3:datetimeのカラムを入力する際、時・分の入力を省略する

Posted at
add.ctp
            echo $this->Form->input('mydate',
                                     [
                                       'label'      => '日付',
                                       'type'       => 'date',
                                       'dateFormat' => 'YMD',
                                       'monthNames' => false,
                                       'minYear'    => date('Y') - 3,
                                       'value'      => date('Y-m-d')
                                     ]
                                   );
            echo $this->Form->hidden('mydate[hour]',   ['value' => '0' ]);
            echo $this->Form->hidden('mydate[minute]', ['value' => '00']);

キモは'type'に'datetime'ではなく'date'を指定すること。
これにより年月日のプルダウンが表示されます。

足りない時・分についてはhiddenにて固定値を設定します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0