Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2231

Ajax form submits all possible radio values

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.4
    • Fix Version/s: 5.4
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      Just notised a strange issue with radio ajax/zone submit. It submits all values - selected and not selected.

      • If I disable javascript - then it submits single value. Correct
      • If I remove form t:zone then it also submits fine. Correct

      If I enable t:zone then it submits all possible radio values.

      Simple test case:

      tml
      <h2>Selected type: ${type}</h2>
      <t:zone t:id="formZone">
      	<t:form t:zone="^" t:id="radioForm">
      
      		<t:label for="type" />:
      
      		 <t:radiogroup t:id="type">
      			<t:radio t:id="masterCard" />
      			<t:label for="masterCard" />
      			<t:radio t:id="visa" />
      			<t:label for="visa" />
      			<t:radio t:id="amex" />
      			<t:label for="amex" />
      			<t:radio t:id="dinersClub" />
      			<t:label for="dinersClub" />
      			<t:radio t:id="discover" />
      			<t:label for="discover" />
      		</t:radiogroup>
      		
      		<t:submit/>
      
      	</t:form>
      </t:zone>
      
      java
      public enum CardType{MASTER_CARD, VISA, AMERICAN_EXPRESS, DINERS_CLUB, DISCOVER}
      
      @InjectComponent private Zone formZone;
      @Inject private Request request;
      
      @Property
      @Persist
      private CardType type;
      
      public CardType getMasterCard() { return CardType.MASTER_CARD; }
      
      public CardType getVisa() { return CardType.VISA; }
      
      public CardType getAmex() { return CardType.AMERICAN_EXPRESS; }
      
      public CardType getDinersClub() { return CardType.DINERS_CLUB; }
      
      public CardType getDiscover() { return CardType.DISCOVER; }
      
      Object onSubmitFromRadioForm() {
      	return request.isXHR() ? formZone.getBody() : null;
      }
      
      Request Form data

      t:zoneid:formZone
      t:submit:["submit_19b3a276fbae1_0","submit_0"]
      t:formdata:hxLFSgWPQ9kZJpyI3CYQavAif/A=:H4sIAAAAAAAAAFvzloG1XIxBpCS1uEQ/KLW4ID+vOLMs1aqksiC1uIjBIr8oXS+xIDE5I1WvJBEoVFJUaaqXnF+UmpOZBKRzgepT80qK9YISUzLz3YvySwtUglNLSgsmGuzT2cz3+RATA6MPA3dyfl5JUX6OX2JuagmDkE9WYlmifk5iXrp+cElRZl66dUVBCQMLyEo8TjEhwymGpypOndoU/HcfEwNDRUG5BIMYuuHFpUm5mSVA4x2INT4YrEMloCg/ObW4GMwrLs7Mz5sZ/Ely65YWZyYGJh8GjuScTKBqz5RChjpwCKTmpOYCBUAhABYC+VgMYnm8oWWScaKRuVlaUmKqYbxBCQMHVMIAANTuUEWeAQAA
      type:MASTER_CARD
      type:VISA
      type:AMERICAN_EXPRESS
      type:DINERS_CLUB
      type:DISCOVER

      Looks like the "forms.gatherParameters (forms.js)" is adding all values - and not just the checked one.

        Attachments

        1. forms.coffee
          7 kB
          Magnus Kvalheim

          Issue Links

            Activity

              People

              • Assignee:
                hlship Howard M. Lewis Ship
                Reporter:
                magnus@kvalheim.dk Magnus Kvalheim
              • Votes:
                2 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: