[英]Use calendar form field in Joomla
I am using a calendar field in Joomla component template. 我在Joomla组件模板中使用日历字段。
But i have no idea how to use it. 但是我不知道如何使用它。 the example XML field definition is
示例XML字段定义是
<field name="mycalendar" type="calendar" default="5-10-2008" label="Select a date" description="" format="%d-%m-%Y" />
But how to define it in a php template? 但是如何在php模板中定义它?
Thank you! 谢谢!
After using the code, how can i make the calendar icon align with the input box? 使用代码后,如何使日历图标与输入框对齐? now it is like this
现在就是这样
thank you. 谢谢。
hi, as for the code, i am insert the date into database of field name 'from' and 'to', so where do i need to change the code to match that? 嗨,至于代码,我将日期插入字段名“ from”和“ to”的数据库中,那么我需要在哪里更改代码以匹配该代码?
<?php
echo JHTML::calendar(date("Y-m-d"),'from', 'date', '%Y-%m-%d',array('size'=>'8','maxlength'=>'10','class'=>' validate[\'required\']',));
?>
<?php
echo JHTML::calendar(date("Y-m-d"),'to', 'date', '%Y-%m-%d',array('size'=>'8','maxlength'=>'10','class'=>' validate[\'required\']',));
?>
Try this, 尝试这个,
This will add a calendar to the form. 这会将日历添加到表单。
<?php
echo JHTML::calendar(date("Y-m-d"),'mycalendar', 'date', '%Y-%m-%d',array('size'=>'8','maxlength'=>'10','class'=>' validate[\'required\']',));
?>
Hope its helps.. 希望能有所帮助
You need to add the following line at the top of your output file: 您需要在输出文件的顶部添加以下行:
JHTML::_('behavior.calendar');
And if your XML is correct everything should work. 而且,如果您的XML是正确的,那么一切都应该正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.