fix: validate cardinality contidion value

This commit is contained in:
vnmedeiros 2021-09-13 17:46:10 -03:00
parent bedd353913
commit e5a9afb61d
2 changed files with 2 additions and 5 deletions

View File

@ -487,7 +487,7 @@ class Item_Metadata_Entity extends Entity {
if ($this->is_multiple()) {
if (is_array($value)) {
$cardinality = $metadatum->get_cardinality();
if ( !empty($cardinality) && $cardinality > 0 && count($value) > $cardinality ) {
if ( !empty($cardinality) && $cardinality > 1 && count($value) > $cardinality ) {
$this->add_error( 'invalid', sprintf( __('Metadatum %s is set to accept a maximum of %s values.', 'tainacan'), $metadatum->get_name(), $cardinality ) );
return false;
}

View File

@ -365,10 +365,7 @@
},
watch: {
showCardinalityOptions() {
if (!this.showCardinalityOptions)
this.editForm.cardinality = 2;
else
this.editForm.cardinality = 1;
this.editForm.cardinality = !this.showCardinalityOptions ? 1 : 2;
}
},
created() {