ฉันใช้ datepicker เริ่มต้นดังนี้:
echo $this->Form->control(
'created',
[
'label' => __('Start date'),
'type' => 'date',
'id' => 'datetimepicker',
'default' => date('d-m-Y') #Set time for today
]
);
แต่มันน่าเกลียดมาก:
เป็นไปได้ไหมที่จะเปลี่ยนเป็น datepicker ที่เหมาะสมพร้อมปฏิทินแทนที่จะเป็น 3 ฟิลด์แบบเลื่อนลง
ถ้าไม่เช่นนั้น อย่างน้อยที่สุดก็สามารถเปลี่ยนลำดับของฟิลด์และภาษาได้?
แก้ไข
หลังจากข้อเสนอแนะความคิดเห็น ฉันตัดสินใจใช้ jquery datepicker เช่นนี้:
echo $this->Form->control('created', ['label' => 'Start date']);
<script>
$( function() {
$( "#created" ).datepicker();
} );
</script>
แต่ (อาจเป็นไปได้) เนื่องจาก created
id อยู่ในโมเดล จึงมีการลบล้างมันและแสดง datepicker เริ่มต้นเดียวกัน ฉันจึงต้องเปลี่ยน id เพื่อให้ทำงานได้ แต่ค่าของมันจะไม่ถูกบันทึก....
ถ้าฉันตั้งค่าประเภทเป็นข้อความ มันจะแสดงปฏิทิน jquery แต่วันที่ที่บันทึกคือ 0000-00-00 00:00:00
text
และรวม JS datepicker lib ใด ๆ - person Girish   schedule 19.10.2018type
likeecho $this->Form->input('created', ['label' => 'Start date', 'type' => 'text']);
- person Girish   schedule 19.10.20180000-00-00 00:00:00
- person netdev   schedule 19.10.2018$tableEntity->set('created', $this->request->data('created'));
FYI: รูปแบบข้อมูลควรY-m-d H:i:s
- person Girish   schedule 19.10.2018Model/Entity/CustomerServiceType.php
แต่ฉันได้รับข้อผิดพลาด › ข้อผิดพลาดทางไวยากรณ์, '$tableEntity' ที่ไม่คาดคิด (T_VARIABLE), ฟังก์ชันที่คาดหวัง (T_FUNCTION) หรือ const (T_CONST) - person netdev   schedule 19.10.2018