1. #1
    Sencha User
    Join Date
    Feb 2008
    Vote Rating
    danellison is on a distinguished road


    Question [3.1.1] multiple RadioGroups with same name - getValues not returning array

    Greetings again. I have a function that returns a repeating set of form fields that are encapsulated within a FormPanel. The repeating set includes both text fields and a radio group. On calling the getValue method on the form panel all text fields are correctly converted to arrays (as expected). RadioGroups elements are not. The repeating block of radiogroup code:

    new Ext.form.RadioGroup({
    	width: 160,
    	columns: 3,
    	items: [
    		{boxLabel: 'AND', name: 'modifier', myIndex: ndex, inputValue: 'AND', 
    			listeners: {
    				check: addANDORExpression}
    		{boxLabel: 'OR', name: 'modifier', myIndex: ndex, inputValue: 'OR', 			listeners: {
    				check: addANDORExpression}
    		{boxLabel: 'None', name: 'modifier', myIndex: ndex, checked: true, inputValue: 'None', listeners: {check: removeQTerm}},
    		{boxLabel: 'EOC', name: 'modifier', hidden: true, inputValue: 'END', checked: true}
    With multiple instanciations of a "form group" I get an array for my non-RadioGroup elements but only a single value for a repeated radiogroup.

    Any ideas on where I am going wrong here?

    Thanks in advance,

    [added info]
    After deeper consideration of what a radiogroup really is (duh - already an array of radio buttons....) it is clear that this is really the only way for them to behave. When used as I attempted to use them above we will always end up with the value from the last group in the form since we can't distinguish one groups value from another. In order to use a repeating set of form fields with a radiogroup within them you either have to deal with naming the elements as array elements, id: 'radio[0]', which triggers another problem in the DomQuery class not matching the square braces, or as I have done here, use the check event handler to record the current value of the checkbox passed to it into a hidden field. Now each group has a placeholder and we can deal with the selections within each group. The hidden field will be "correctly" processed in the getValues() call and I end up with a synchronized set of arrays as desired. The long way to get there but we got there.
    Last edited by danellison; 18 May 2010 at 11:00 AM. Reason: better understanding