Semantic-ui: [Form Validation] regression: get values with radio returns true or false

Created on 28 Aug 2017  路  11Comments  路  Source: Semantic-Org/Semantic-UI

I've setup two fiddles, one with semantic-ui 2.2.10 from cdn:
https://jsfiddle.net/xev09j67/2/
and one with semantic-ui 2.2.12 from semantic-ui-css package:
https://jsfiddle.net/mjL46gm4/1/

click on GET and SET buttons to show the problem.

Confirmed Bug

Most helpful comment

I'll look at this over the issue and proposed fix over the holidays.

All 11 comments

Hi @kapouer, it seems that it鈥檚 working correctly only when you specifically tell it that the fields are connected with [] postfix, e.g.: name="fruit[]". Since [] postfix only makes sense in the PHP world, and is more of a back-end thing than anything, maybe it鈥檇 be better to automatically apply the same mechanism to multiple instances of name="fruit" pattern within a single form.

This is a regression, introduced in 86ea20d5a09463cda6f2e98dacb824c23ee0b592

See this comment

This is pretty critical I would say.

Broke my app also.

a quick workaround

in semantic.js: line 1103

                 if(isRadio) {
                    if(values[name] === undefined ||聽values[name] == false ) {
                     values[name] = (isChecked) ? value ||聽true : false;
                    } 
                 }

a quick workaround

This is still not correct. The value should not be a boolean, but a value of the radio element selected.

That what you will have! the value of the selected radio element, but in some case people use radio input without "value" attribute and if you do you will have a boolean value....

ahhh yes you are right, I mis-read the ||

I'll look at this over the issue and proposed fix over the holidays.

I've merged in the fix from @tincdev, I believe it is the correct approach.

Will be fixed in 2.2.14 released later tonight.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arj-196 picture arj-196  路  3Comments

deneuxa picture deneuxa  路  3Comments

miguelmota picture miguelmota  路  3Comments

guilhermeblanco picture guilhermeblanco  路  3Comments

ghost picture ghost  路  3Comments