简体   繁体   中英

Use calendar form field in Joomla

I am using a calendar field in Joomla component template.

But i have no idea how to use it. the example XML field definition is

<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?

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?

<?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.

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