Okay
  Public Ticket #3709861
Feature: Datepicker adjustment
Closed

Comments

  •  1
    Corsin started the conversation

    If you want additional user information for the forms, such as the date of birth of the customer, then the current date picker is not optimal for selecting a date of birth which is 20 or 30 years old. It would better make sense to select year and month in a dropdown or similar. At the moment you have to laboriously click through all the years and months.

    This is my feedback and feature request, thanks and regards
    Corsin

  •  698
    Stefan replied

    Hi Corsin,

    Thanks for reaching out to us and for the suggestion. 

    You're welcome to browse our feature suggestion page to check if someone has already proposed the feature you're thinking of. If you don't find it, feel free to add your suggestion. As more people vote for it, the feature will climb higher on our priority list.

    Additionally, you can stay updated by following our changelog page, where we announce any changes, new features, and bug fixes in updates. You can also subscribe to our newsletter to receive updates on new features, bug fixes, freebies, and more.


    Kind Regards, 

    Stefan Petrov
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •   Corsin replied privately
  • Gov replied

    Hi, a solution can be to do yourself the datepicker : create an input ( type text ) and onclick open a datepicker.

    The difficulty is that there is no class or id specified for the input, but there is for the label, when required.

    1. Create a custom field, input type text ( ID: 14 for example )

    2. Call yourself Datepicker with wordPress ( inside functions.php ) : 

    add_action('wp_enqueue_scripts', 'add_scripts_datepicker');
    function add_scripts_datepicker() {
        wp_enqueue_script('jquery-ui-datepicker');
        wp_enqueue_style('jquery-ui-css', 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css');
    }

    3.  Add this code in a custom js also called in your functions.php : 


    window.ameliaActions = {
      InitInfoStep: function (success = null, error = null, data) {
        console.log('InitInfoStep HOOK');

        // Fonction pour initialiser un Datepicker et ajouter le formatage
        function initDatepickerForInput(input) {
          if (input) {
            // Initialiser le Datepicker
            jQuery(input).datepicker({
              dateFormat: 'dd/mm/yy',
              changeMonth: true,
              changeYear: true,
              yearRange: '-90:-12',
              defaultDate: new Date(1980, 0, 1),
            });


    // ( i added the possibility to enter dd/mm/yyyy ) it is optionnal

           input.addEventListener('input', function () {
      let value = this.value.replace(/[^0-9]/g, ''); 

      // Ajouter le '/' après les 2 premiers caractères (jour)
      if (value.length >= 2) {
    value = value.slice(0, 2) + '/' + value.slice(2);
      }

      // Ajouter le '/' après les 4 premiers caractères (mois) si la longueur dépasse 4 caractères
      if (value.length >= 5) {
    value = value.slice(0, 5) + '/' + value.slice(5);
      }

      // Limiter la longueur à 10 caractères (dd/MM/yyyy)
      if (value.length > 10) {
    value = value.slice(0, 10);
      }

      this.value = value;
    });

          }
        }

        // Initialiser le Datepicker pour cf14
        const labelCf14 = document.querySelector('label[for="cf14"]');
        if (labelCf14) {
          const inputCf14 = labelCf14.nextElementSibling.querySelector('.el-input__inner');
          initDatepickerForInput(inputCf14);
        }

      }
    };

    ** I se no other solution to target an input from a custom field, but you can always target the 2nd input, 3rd etc... if it is not required and you have no label to target.

    Tell me if it helps 

  •  698
    Stefan replied

    Hello Gov,

    Thanks for the workaround. I will leave this ticket on public so other people can see it and potentially implement the solution. 

     

    Kind Regards, 

    Stefan Petrov
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables