diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index 4c01ef24b..765bf5381 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -1184,17 +1184,26 @@ class Item extends Entity { if ( $metadata_section->is_conditional_section() ) { $rules = $metadata_section->get_conditional_section_rules(); + if ( !empty($rules) ) { foreach ( $rules as $meta_id => $meta_values_conditional ) { $meta_values = []; $metadatum = new \Tainacan\Entities\Metadatum($meta_id); $metadatum_type = $metadatum->get_metadata_type_object(); + if ( $metadatum_type->get_primitive_type() == 'term' ) { $item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($this, $metadatum); - $term_values = $metadatum->is_multiple() ? $item_metadata->get_value() : array( $item_metadata->get_value() ); - $meta_values = array_map(function($term) { - return $term->get_id(); - }, $term_values); + + if ( $metadatum->is_multiple() ) { + $term_values = $item_metadata->get_value(); + $meta_values = array_map(function($term) { + return $term->get_id(); + }, $term_values); + } else { + $term_values = $item_metadata->get_value(); + $meta_values = $term_values == false ? [] : $term_values; + } + } else { $item_id = $this->get_id(); $meta_values = get_post_meta( $item_id, $meta_id ); diff --git a/src/views/admin/components/edition/item-edition-form.vue b/src/views/admin/components/edition/item-edition-form.vue index f9c1c92cc..aa42fc978 100644 --- a/src/views/admin/components/edition/item-edition-form.vue +++ b/src/views/admin/components/edition/item-edition-form.vue @@ -397,7 +397,7 @@ {{ Number(sectionIndex) + 1 }}. @@ -443,7 +443,7 @@ :hide-help-buttons="false" :help-info-bellow-label="false" :is-mobile-screen="isMobileScreen" - :enumerate-metadatum="metadataSections.length > 1 && collection.item_enable_metadata_enumeration === 'yes' ? ( (Number(sectionIndex) + 1) + '.' + (Number(getMetadatumOrderInSection(sectionIndex, itemMetadatum.metadatum)) + 1) ) : false" + :enumerate-metadatum="metadataSections.length > 1 && collection && collection.item_enable_metadata_enumeration === 'yes' ? ( (Number(sectionIndex) + 1) + '.' + (Number(getMetadatumOrderInSection(sectionIndex, itemMetadatum.metadatum)) + 1) ) : false" :is-last-metadatum="index > 2 && (index == itemMetadata.length - 1)" :is-focused="focusedMetadatum === index" :is-metadata-navigation="isMetadataNavigation" @@ -671,7 +671,7 @@