PDA

View Full Version : Ext.form.FieldSet Improvement-Suggestions



tobiu
12 Jun 2008, 8:19 AM
hi team and community,


i worked quite a bit with fieldsets in the last week and found the config-option

checkboxToggle

in my current project (a reservation system) i was asked to build a form for new reservations. within that form, there are 2 fieldsets: one for chosing the customer who wants a new reservation and one for creating a new customer, if the account does not already exists. with some listeners i managed, to collapse the second fieldset if the first one is expanded (in both directions) to simulate a "radio-button"-like version of two fieldsets.

in this case, i would like to only validate and submit the fields in the expanded fieldset. so, the perfect solution would be a config option for fieldsets like:

validateAndSubmitOnCollapsed : Boolean (with default to true)

[maybe there could be 2 options like validateOnCollapsed and submitOnCollapsed, but i think it belongs together.]


i guess, many of the readers got no idea at this point, why the feature is needed.

It's quite simple: imagine a collapsed fieldset (like in my case createCustomer) where i have fields who need allowBlank: false. if i just chose an existing customer, i can not submit the form, because the collapsed (and not needed) fieldset throws errors. if i use allowBlank : true, i would have to check it serverside, that all "must have" fields are filled properly.

this leads me to a second feature-request:

setAllowBlank(Boolean) for Ext.Form.Fields like TextFields etc.

It would be really cool to be able to decide on events, if a field is a "must be filled" one or not.

3rd requests:

isCollapsed() for Ext.form.FieldSet. important one!


4th request:

validator : Function for Fields like TextField. i tried a validator function like (minLength- handmade):



validator: function(){
if(foodlistFieldsetCollapsed == false) { // variable, because of request 3
if(reservationForm.getForm().findField('foodKind').getValue().length < 2){
return 'Field needs 2 chars.';
}
}
return true;
}


when i type one char in the field (or just click into it), the validator works fine. if i leave the field empty, without clicking into it and submit the form, all standard validators are called, but not the selfmade ones: i would be able to submit the empty field.

so: onSubmit call all field-validator functions by default is my last one =)


if there are already solutions for request 1 and 2, please let me know. i can imagine many cases of collapsed fieldsets that only shall be submitted if expanded, so to my opnion many users need it.


kind regards, tobiu

tobiu
14 Jun 2008, 5:26 AM
for now, i managed the problem with disabling all elements of a fieldset on collapsing it and enabling them on expand, as disabling prevents validate and submit.