Add a checkbox field on editor

Add a checkbox field on editor

hminhduchminhduc Posts: 22Questions: 13Answers: 1

How can add a type checkbox field, and handle event when click on that

Thanhyou!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin

    To handle the event from such a field, you could either use dependent() (which I would recommend) or field().input() to get the input elements and then attach your custom event handler.

    What do you want your event handler to do?

    Allan

  • hminhduchminhduc Posts: 22Questions: 13Answers: 1

    Thank for reply, i have a checkbox on form editor. So when checked that, some other field must disable for cannot input.

  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    edited September 2022 Answer ✓

    dependenat() sounds perfect for that:

    editor.dependent('myCheckbox', function (val) {
      if (val == 1) {
        editor.field('myOtherField').disable();
      }
      else {
        editor.field('myOtherField').enable();
      }
    
      return {};
    });
    

    Allan

Sign In or Register to comment.