@mutt/forms
Advanced tools
Comparing version 2.4.0 to 2.5.0
{ | ||
"name": "@mutt/forms", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -55,3 +55,5 @@ /** | ||
for (const fieldName of Object.keys(resolvedProps)) { | ||
let fieldId = `${name}_${fieldName}` | ||
let fieldId = options.usePathId | ||
? `${id}_${fieldName}` | ||
: `${name}_${fieldName}` | ||
let fieldOptions = {} | ||
@@ -71,2 +73,6 @@ let fieldRequired = false | ||
if (!fieldOptions.hasOwnProperty('usePathId')) { | ||
fieldOptions.usePathId = options.usePathId | ||
} | ||
let field = this.constructor.new( | ||
@@ -73,0 +79,0 @@ fieldId, |
@@ -206,2 +206,5 @@ /** | ||
let fieldIdPrefix = '' | ||
let usePathId = false | ||
if (schema.hasOwnProperty("title")) { | ||
@@ -215,2 +218,12 @@ fieldsetSpec.label = schema.title | ||
} | ||
// If this idPrefix is set in form's options we prefix the fields ids | ||
if (options.form.hasOwnProperty("idPrefix")) { | ||
fieldIdPrefix = `${options.form.idPrefix}_` | ||
} | ||
// If 'usePathId' is set to true in form's options we use "full path" ids | ||
if (options.form.hasOwnProperty("usePathId")) { | ||
usePathId = options.form.usePathId | ||
} | ||
} | ||
@@ -232,3 +245,5 @@ | ||
for (const fieldName of Object.keys(schema)) { | ||
let fieldId = `${fieldName}_field_${fieldIndex}` | ||
let fieldId = usePathId | ||
? `${fieldIdPrefix}${fieldName}_field` // Hierarchical/full path ids | ||
: `${fieldIdPrefix}${fieldName}_field_${fieldIndex}` // Usual ids | ||
let fieldSchema = schema[fieldName] | ||
@@ -255,2 +270,8 @@ let fieldOptions = {} | ||
// If userPathId is not explicitly set in this field's options, | ||
// we pass the default/form usePathId down to the fields options | ||
if (!fieldOptions.hasOwnProperty('usePathId')) { | ||
fieldOptions.usePathId = usePathId | ||
} | ||
let field = Field.new(fieldId, fieldName, fieldSchema, fieldOptions) | ||
@@ -257,0 +278,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
292315
4527
0