How to add calendar controls to a Joomla administrator component

Being home during summer holiday means doing some “home development”. Being forced to do a re-make of the feestbordindetuin I found a nice component for showing products and categories (DJ Catalog), without having to implement a whole e-commerce-solution. One of the disadvantages is that is doesn’t support the administration of customers and reservations so I built that myself using the MVC structure for Joomla components. Customers can make a reservation for a product, having a start-date and an end-date and of course a reference to the product itself. I wanted to be able to edit the dates myself but I also wanted a calendar-control, well that was easy:

<input class="text_area" type="text" name="date_from" id="date_from" size="32" maxlength="250" value="<?php echo $this->item->date_from;?>" />
<img id="date_from_img" alt="calendar" src="/templates/system/images/calendar.png" class="calendar" onclick="return showCalendar('date_from','%d-%m-%Y');" >

Just add an image next to the input type and don’t forget to add the calendar behaviour on top of your form:


JHTML::_('behavior.calendar');

Tada:

joomla-dates
Making a reservation for a product using the Joomla built-in calendar control.

Geef een reactie