views:

40

answers:

1

Some of the forms represent parent objects and I want most field disabled in each of these forms, if they're for a 'parent' object. Is there an easy way to do this?

A: 

The easiest way is to give the fields a particular semantic class, and then disable all the ones with that class using jQuery. Assuming the forms are all contained in some larger container with an id of formgroup and you use dependent-field as the class name, you can use something like:

// Set the 'disabled' attribute on every dependent field in this group of forms.
$('#formgroup').find('.dependent-field').attr('disabled', true);
John Feminella