dstreet / dependsOn

a jQuery plugin for handling form field dependencies
http://dstreet.github.com/dependsOn
MIT License
106 stars 32 forks source link

Add 'readonly' as an option in addition to 'disabled' #4

Closed onshop closed 9 years ago

onshop commented 10 years ago

My form fields will not validate if disabled when using Zend Framework. The way to get round this is to set them with the attribute 'readonly' so it would be nice to have this as an additional option.

onshop commented 10 years ago

I have a workaround:

$("#business_case").dependsOn({
    '#has_business_case': {
        values: ['1']
    }
}, {
    hide: false,
    onDisable: function() {
        $('#business_case').removeAttr("disabled").prop("readonly", "readonly");
    }
});
dstreet commented 10 years ago

@onshop, I agree that there should be a little more flexibility in the way the plugin handles "disabling" a field. I'm considering making an option to either add the disabled attribute, readonly attribute, or do nothing at all (allowing the user to handle the disabled state on their own).