1

I want to disable week days (Saturday & Sunday) in admin form calendar field. check below screen-shoot.

enter image description here

Below is my field code.

$fieldsetDirector->addField(
        'attendance', 'date',
        [
        'name' => 'attendance',
        'label' => __('Attendance'),
        'title' => __('Attendance'),
        'date_format' => 'yyyy-MM-dd',
        'id' => 'attendance'
        ]
    )

1 Answer 1

0

Set the DatePicker so no weekend is selectable

$fieldsetDirector->addField(
        'attendance', 'date',
        [
        'name' => 'attendance',
        'label' => __('Attendance'),
        'title' => __('Attendance'),
        'date_format' => 'yyyy-MM-dd',
        'id' => 'attendance'
        ]
    )->setAfterElementHtml(
        '<script>
            require([
                 "jquery",
            ], function($){
                $(document).ready(function () {
                    $( "#attendance" ).datepicker({
                      beforeShowDay: $.datepicker.noWeekends
                    });
                });
              });
       </script>'
    );
4
  • How to implement this script in my code? i know how to disable days in calendar, but issue is how to implement this script in my code Commented Jun 17, 2018 at 16:31
  • i update your answer, please check here how script implement to magento backend form. Commented Sep 26, 2018 at 12:30
  • Thanks man for converting JQ to mAgento Implementation. Commented Sep 26, 2018 at 12:31
  • For more reference check this link magento.stackexchange.com/questions/225226/… Commented Sep 26, 2018 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.