简体   繁体   中英

ExtJS - submitting disabled checkbox

Version 4.2.1

In a form I use a checkbox which should not be changed for a certain type of user. So I disable the checkbox and set checked and value to `true. I want this value to be submitted.

        {
          name: 'myName',
          itemId: 'myItemId',
          xtype: 'checkboxfield',
          fieldLabel: "test",
          checked: true,
          value: true,
          disabled: true,
        }, 

When I submit the form I see that there is no parameter for this checkbox.
Only when I set disabled to true I get a parameter with value on

When I look at:

    var data = form.getValues();
    console.log(data);

this checkbox is not submitted with an on value.

When I use readonly: true I can check/uncheck the checkbox and that value is submitted.

So how can I disable the checkbox for editing, set the value to checked and get it submitted to the server?

Found this thread from 2008/2009 which has a simple solution.

Form Submit is not sending values of disabled field
Sending disabled field

This code sets the checkbox to readonly is shown and a user cannot change the value. And the field is submitted to the server.

readOnly: true,
fieldClass: "x-item-disabled"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM