Don't display non-unique field error if field name is empty
This commit is contained in:
parent
fe58af883d
commit
e0137cd541
1 changed files with 6 additions and 2 deletions
|
@ -65,7 +65,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
v-if="form.fields_attributes.length <= extraFieldMaxCount"
|
v-if="canAddExtraField()"
|
||||||
type="button"
|
type="button"
|
||||||
class="add-extra-field"
|
class="add-extra-field"
|
||||||
@click="addExtraField()"
|
@click="addExtraField()"
|
||||||
|
@ -174,7 +174,7 @@ function isValidExtraField(index: number): boolean {
|
||||||
const field = form.fields_attributes[index]
|
const field = form.fields_attributes[index]
|
||||||
for (let prevIndex = 0; prevIndex < index; prevIndex++) {
|
for (let prevIndex = 0; prevIndex < index; prevIndex++) {
|
||||||
const prevField = form.fields_attributes[prevIndex]
|
const prevField = form.fields_attributes[prevIndex]
|
||||||
if (field.name === prevField.name) {
|
if (field.name && field.name === prevField.name) {
|
||||||
// Label is not unique
|
// Label is not unique
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -186,6 +186,10 @@ function removeExtraField(index: number) {
|
||||||
form.fields_attributes.splice(index, 1)
|
form.fields_attributes.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canAddExtraField(): boolean {
|
||||||
|
return form.fields_attributes.length <= extraFieldMaxCount
|
||||||
|
}
|
||||||
|
|
||||||
function addExtraField() {
|
function addExtraField() {
|
||||||
form.fields_attributes.push({ name: "", value: "", value_source: "" })
|
form.fields_attributes.push({ name: "", value: "", value_source: "" })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue