[SOLVED] How to implement calendars in a form??

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
ghostrifle
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Wed Aug 22, 2007 8:41 am
Location: Germany
Contact:

[SOLVED] How to implement calendars in a form??

Post by ghostrifle » Tue Oct 02, 2007 2:29 pm

Hi there,

I'm trying to use the calendar provided with joomla in the component. I'm using the following code to display the calendar:

Code: Select all

      <input class="inputbox" type="text" name="valid_from" id="valid_from" size="15" maxlength="10" value="<?php echo $this->rl_ad->valid_to; ?>" />
 <a href="#" onclick="return showCalendar('dates', 'y-mm-dd');"><img class="calendar" src="images/blank.png" alt="calendar" /></a>


In my view-object, I'm preparing the calendar with this code:

Code: Select all

function display($tpl = null)
   {
   ...
      
      JHTML::_('behavior.calendar'); // preparing the calendar
      $body_editor =& JFactory::getEditor();
      
      $this->assignRef( 'body_editor', $body_editor );
       $this->assignRef('rl_ad', $rl_ad);
       parent::display($tpl);
   }


Well the input field with the calendar displays... but when I wanna change the date by clickin on the icon... nothing happens.... so.. what am I doing wrong !??

Thanx, Alex

BTW: I'm using the current SVN
Last edited by ghostrifle on Tue Oct 02, 2007 8:58 pm, edited 1 time in total.
o

ghostrifle
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Wed Aug 22, 2007 8:41 am
Location: Germany
Contact:

Re: How to implement calendars in a form??

Post by ghostrifle » Tue Oct 02, 2007 6:49 pm

The solution to my problem is quite easy:

remove all the code from above and replace with this code for displaying a date value with a popup calendar:

Code: Select all

<?php echo JHTML::_( 'calendar',$value,$name,$id); ?>


Have a look at this api doc for further information: http://api.joomla.org/svn/Joomla-Framework/HTML/JHTML.html#calendar

thanx to Ian MacLennan from J101 Chat
o

aristondarmayuda
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 24, 2006 9:37 am

Re: [SOLVED] How to implement calendars in a form??

Post by aristondarmayuda » Sat Feb 09, 2008 1:58 pm

How about getting the value from calendar, I try to get the value by the name and the ID. For example I use calendar that called fdate then the name will be detail[fdate] and the ID is fdate.

Then I use code like this: $date = JRequest::getVar('detail[fdate]');

The code doesn't work? How to get the date???

Thanks,


Post Reply