craftercms / craftercms

Parent project for Crafter CMS. Issue tracking across all repositories and global builds.
GNU General Public License v3.0
282 stars 98 forks source link

Dropdown form control field should support values of type `_i` and `_f` #6704

Open russdanner opened 3 weeks ago

russdanner commented 3 weeks ago

Latest version

Duplicates

Is your enhancement request related to a problem? Please describe.

CI: N/A

Currently, admins must configure a value of type _s when using a drop-down. In many cases, storing the value as _i or _f would be useful. Currently, admins must configure a value of type _s when using a drop-down.

Describe the solution you'd like

Allow variable types of _i and _f when using a dropdown control

rart commented 3 weeks ago

@jvega190 some things to bear in mind:

jvega190 commented 2 weeks ago

@jvega190 some things to bear in mind:

  • Update any relevant tooltips on the type editor property sheets
  • Check if any piece of the SDK (authoring or delivery parsers) needs updating due to this change

@rart In the SDK, the parseFieldValue validates the type using the suffix, so when _i or _f it'll parse float the value. https://github.com/craftercms/js-sdk/blob/develop/packages/content/src/utils.ts#L206 Tested with the parseFieldValueTypes option set to true, and the value is properly parsed.