Skip to content

Commit

Permalink
fix: options attribute is stored in 'values' key, custom options are …
Browse files Browse the repository at this point in the history
…stored in attribute name key
  • Loading branch information
lucasnetau committed Nov 14, 2024
1 parent 29b4f23 commit 3dfaae2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/js/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ function FormBuilder(opts, element, $) {
* @return {string} field options markup
*/
const fieldOptions = function (fieldName, fieldData) {
const { type, values } = fieldData
const { type } = fieldData
let fieldValues
const optionActions = [m('a', mi18n.get('addOption'), { className: 'add add-opt' })]
const fieldLabel = fieldName === 'values' ? mi18n.get('selectOptions') : i18n[fieldName]
Expand All @@ -406,6 +406,11 @@ function FormBuilder(opts, element, $) {
}
}

/**
* For build-in options attributes the options are stored in the "values" key
* For custom options the options will be in the attribute named key when in saved formData or in the values key when coming from field definition
*/
const values = fieldName === 'options' ? fieldData['values'] : (fieldData[fieldName] || fieldData['values'])
if (!values || !values.length) {
let defaultOptCount = [1, 2, 3]
if (['checkbox-group', 'checkbox'].includes(type)) {
Expand Down

0 comments on commit 3dfaae2

Please sign in to comment.