redux-autoform / redux-autoform-bootstrap-ui

Bootstrap UI extension for redux-autoform
https://redux-autoform.github.io/redux-autoform-bootstrap-ui/demo.html
MIT License
6 stars 11 forks source link

How to disable field in a form conditionally ? #77

Closed nikhilarunw closed 7 years ago

nikhilarunw commented 7 years ago

I want to disable a field in form conditionally. I am using TextBox component and datatype is string. I have tried setting disable and readOnly props in Entity Schema for a specific field but it is still editable in form.

Entity schema is as follows:

entities: [
  {
            name: "signup",
            fields: [{
                name: "parent_name",
                displayName: "Parent Name",
                placeholder: "Parent Name",
                component: "TextBox",
                type: "string",
                error: function(m){
                    return m.parent_name ? "" : "Please enter a parent name";
                },
                disabled: function(m){
                    return m.age > 21 ? false: true;
                },
               readOnly: function(m){
                    return m.age > 21 ? false: true;
               }
            },{
                name: "age",
                displayName: "Age",
                placeholder: "Age",
                type: "number"
             }]
   }
]

From repository code it looks like disable or readOnly feature has not implemented or Am I missing any configuration ?

JonatanSalas commented 7 years ago

For now, disable and readOnly are not implemented. You can use the visible attribute, so you can show this only when you need to show it.

nikhilarunw commented 7 years ago

Thank you @JonatanSalas.

JonatanSalas commented 7 years ago

@nikhilarunw you are welcome!