forms icon indicating copy to clipboard operation
forms copied to clipboard

Allow disabled choices

Open TomKremer opened this issue 8 years ago • 2 comments

Set the third value in choices to TRUE to disable an item on the list.

TomKremer avatar Dec 22 '16 14:12 TomKremer

i gotta comment even though I’m not a maintainer but it’s my code you’re changing :).

i like the idea, but apart from the fact, that this change only provides an array syntax for specifying disabled options, i always feel like options that use designated array indexes are hard to remember and force developers to look at the docs a lot because they forgot which option is which array-index. the wish to omit the disable or default flag (this pr introduces both as of now) and the need to have special values to skip an array index is another problem i see with this implementation.

why not keep the current format as it is and add defaults and disabled values as individual field options? iirc values are unique for each field and you could just build object where choice values map to default values/ disabled flags. that’d be backwards compatible, easy to remember and you probably would’t have to touch any code beside the choice renderer.

btw. how do you see choice defaults working out? i might be mistaken but I don’t see the point because you already have full control over the values as the user simply selects given choices.

kmohrf avatar Dec 30 '16 18:12 kmohrf

I haven't truly yet understood this PR, but I agree that anything that requires remembering or matching array indices is just not a good API.

ljharb avatar Dec 30 '16 18:12 ljharb