Single-select value doesn't submit with form after change

Jeremy Zorn October 12, 2015

I have a form that includes a select field using https://docs.atlassian.com/aui/latest/docs/single-select.html. That field is pre-populated with the current value, and if I don't change it, posting the form works fine -- that field's value is posted. However, if I switch to a different option, the field does NOT post with the form, and I can't figure out why.

Here's the relevant snippet:

<div>
  <label for="data-selector">Form Label</label>
  <aui-select id="data-selector" name="data-field" src="getOptionsList.php">
    <aui-option selected value="$currentValue">$currentName</aui-option>
  </aui-select>
</div>

And here's a snippet of what that generates in the source of the page:

<input type="text" class="text" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false" id="data-selector" aria-controls="aui-uid-0" aria-activedescendant="null">
<select name="data-field">
  <option selected="true" value="14980">Name</option>
</select>

If I submit the form right now, the data posted would include {"data-field": "14980"}

After selecting a different option, however, here's what the source looks like:

<input type="text" class="text aui-alignment-target aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false" id="data-selector" aria-controls="aui-uid-0" aria-activedescendant="null" aria-busy="false">
<select name="data-field">
  <option selected="true" value="15083">NewName</option>
</select>

I'd therefore expect, when I submit the form, the data posted to include {"data-field": "15083"}. But it doesn't. I've made the submit button do nothing but console.log the form data, and it's clear: for some reason, changing the value of that select form removes it from the data

Here's a screenshot of the console demonstrating that, for some reason, there's one fewer object in the form data after I change the value of that select: http://i.stack.imgur.com/gupvR.png

Help!

6 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Jeremy Zorn October 14, 2015

Sorry, I'm not quite sure what you're asking for. Can you elaborate? That first snippet is how the field is populated, unless you're asking to see getOptionsList.php? I really don't think that's the issue -- as you can see, the appropriate options do get to the source of the page.

0 votes
Alok Singh October 14, 2015

Can you show how you are populating the field?

0 votes
Jeremy Zorn October 14, 2015

Sorry for the slow response -- apparently I'm rate-limited to 1 comment or post per day as a new user with no reputation. Yes, this is the only select with that name.

0 votes
Chris Whitten [Comskil] October 13, 2015

Is it the only select with the name data-field?

0 votes
Jeremy Zorn October 13, 2015

I do, and that part works fine. (I truncated that part of the code in the snippet above.)

0 votes
GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 12, 2015

Who populates $currentValue and $currentName?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events