Has anyone successfully implemented a datepicker (js) in eform?
Have you tried the jQuery UI date picker?
-
☆ A M B ☆
- 24,524 Posts
The one used by MODx is in manager/media/calender. It’s based on mootools, which is also included in MODx in manager/media/script/mootools.
Here’s how it’s used in the date type TVs
$field_id = str_replace(array('-', '.'),'_', urldecode($field_id));
if($field_value=='') $field_value=0;
$field_html .= '<input id="tv'.$field_id.'" name="tv'.$field_id.'" class="DatePicker" type="text" value="' . ($field_value==0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />';
$field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].value=\'\';document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><img src="media/style/'.($manager_theme ? "$manager_theme/":"").'images/icons/cal_nodate.gif" width="16" height="16" border="0" alt="No date"></a>';
$field_html .= '<script type="text/javascript">';
$field_html .= ' window.addEvent(\'domready\', function() {';
$field_html .= ' new DatePicker($(\'tv'.$field_id.'\'), {\'yearOffset\' : '.$modx->config['datepicker_offset'].'});';
$field_html .= '});';
$field_html .= '</script>';
Susan,
How do we actually implement that into a form? Just copy and paste into our form tpl?
MySQL: 5.0.45
PHP: 5.2.6
Linux 2.6.9-023stab048.6-enterprise #1
cURL enabled
PDO enabled
FFox Apple 3.6.8
Firebug DIS-abled
-
☆ A M B ☆
- 24,524 Posts
From the looks of it, you just need to add the javascript in its tags, and add the onclick events to the form fields involved.
I’m referring to yours (using the manager’s datepicker) and not sinbad’s. Are you?
Thanks.
MySQL: 5.0.45
PHP: 5.2.6
Linux 2.6.9-023stab048.6-enterprise #1
cURL enabled
PDO enabled
FFox Apple 3.6.8
Firebug DIS-abled
-
☆ A M B ☆
- 24,524 Posts
Yes; the sample code I posted was taken directly from the tmplvars.inc.php file in the manager/includes folder. You will need to include the mootools library file and the datepicker.js file from manager/media/calendar.
You can call me an idiot if you like. I posted that code into the header and of course it doesn’t do anything. See the image attached.
I did find an awesome online form generator to use in my forms. I basically can’t stand all the time it takes to create forms and I knew there had to be a better way. So after trying this:
http://www.phpform.org/
I bought this:
http://www.appnitro.com/
That way I can copy and paste into various TPLs. I’m sticking it all into my sandbox domain for porting to other MODx sites.
What do you think?
MySQL: 5.0.45
PHP: 5.2.6
Linux 2.6.9-023stab048.6-enterprise #1
cURL enabled
PDO enabled
FFox Apple 3.6.8
Firebug DIS-abled