We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4749
    • 623 Posts
    Has anyone successfully implemented a datepicker (js) in eform?
      The MODx has you...
      Utah Web Design
      • 13736
      • 345 Posts
      Have you tried the jQuery UI date picker?
        • 19951
        • 1 Posts
        Hi, I know this is an old thread, but I was looking for the same and found this one:

        http://www.frequency-decoder.com/2009/02/03/unobtrusive-date-picker-widget-v4/

        Wich seems pretty complete and with a nice design.

        Is there a default datetimepicker for modx? How can you use in the front end the one that appears in the admin panel?
          • 28042 ☆ 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>';
          
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 27330
            • 884 Posts
            i’m using this one. works awesome and super customize imho.
            http://www.electricprism.com/aeron/calendar/
              • 19132
              • 199 Posts
              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
                • 28042 ☆ 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.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 19132
                  • 199 Posts
                  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
                    • 28042 ☆ 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.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 19132
                      • 199 Posts
                      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