Element: [Bug Report] wrong el-select value while submit

Created on 22 Nov 2017  ·  7Comments  ·  Source: ElemeFE/element

Element UI version

2.0.5

OS/Browsers version

Windows 10 / Chrome

Vue version

2.5.8

Reproduction Link

https://jsfiddle.net/6gqc5dj1/1/

Steps to reproduce

  1. Have el-select inside of el-form
  2. Make sure select has "name" scpecified and select some option with different name and value like {value: "1", label: "label1"}
  3. Submit form using el-button with native-type="submit"
  4. Check submited request params for select's name. There will be "label1"

What is Expected?

Expected server will recieve select's value.

What is actually happening?

Server recieve select's label. This way when multiple=false component works just like input.

select

Most helpful comment

Native form submit is not preferred in SPA.
If you insist, it's better using a type="hidden" input and bind a value with el-select.

All 7 comments

Native commit events will refresh the page,so the value will be init。
If you want to push something to the server,you can use post request。

@LastHeaven issue not about refreshing page, there is different topic. Post or Get does not matter. Not every app needs ajax and there is native-type=submit for native posting so form must work as native and "select" must submit it's value not "label".

Native form submit is not preferred in SPA.
If you insist, it's better using a type="hidden" input and bind a value with el-select.

@firesh why do you speak about SPA? I dont need such advices, i know about it, but there is different topic! We have functionality (native-type=submit) for submit forms natively and it do not work properly with el-select.
Please stop speak about Ajax and SPA.

The el-select value property supports string/number/object, and native from value is only supports string/number, I think that's why native submit value is label property but not value property.
Wish you good luck.

image

In the current implementation of Select, what you see in the input box (in this case, 'second') is exactly the value of the <input> element. It's different from the binding value (in this case, 2). So you'll have to modify the FormData if you wish to use native form submit.

Making Select compatible with native form submit requires a major refactor, so I'm leaving this issue open to see if this is a popular demand.

Closing this issue since no other user is requesting this feature.

Was this page helpful?
0 / 5 - 0 ratings