Merge branch 'develop' of https://github.com/tainacan/tainacan into develop
This commit is contained in:
commit
89d184f9dc
|
@ -493,7 +493,7 @@ class REST_Fields_Controller extends REST_Controller {
|
|||
if($method === \WP_REST_Server::READABLE) {
|
||||
$endpoint_args['fetch'] = [
|
||||
'type' => 'string',
|
||||
'description' => __('Fetch all values of a field from a collection in all it collection items'),
|
||||
'description' => __('Fetch all values of a metadata within a collection'),
|
||||
'enum' => ['all_field_values']
|
||||
];
|
||||
$endpoint_args['context'] = array(
|
||||
|
|
|
@ -41,8 +41,6 @@ class Capabilities {
|
|||
"read"
|
||||
],
|
||||
"contributor"=> [
|
||||
"delete_posts",
|
||||
"edit_posts",
|
||||
"read"
|
||||
],
|
||||
"subscriber"=> [
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
use Tainacan\Entities\Field;
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
|
@ -60,4 +62,17 @@ class Core_Description extends Field_Type {
|
|||
|
||||
}
|
||||
|
||||
public function validate_options( Field $field ) {
|
||||
|
||||
if ( !in_array($field->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||
return true;
|
||||
|
||||
if ( $field->get_multiple() != 'no') {
|
||||
return ['multiple' => __('Core Metadata can not accept multiple values', 'tainacan')];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
use Tainacan\Entities\Field;
|
||||
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
|
@ -60,4 +63,17 @@ class Core_Title extends Field_Type {
|
|||
|
||||
}
|
||||
|
||||
public function validate_options( Field $field ) {
|
||||
|
||||
if ( !in_array($field->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||
return true;
|
||||
|
||||
if ( $field->get_multiple() != 'no') {
|
||||
return ['multiple' => __('Core Metadata can not accept multiple values', 'tainacan')];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -138,4 +138,37 @@ class CoreFieldTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
function test_dont_allow_multiple() {
|
||||
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'test',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$fields = $Tainacan_Fields->fetch_by_collection( $collection, [], 'OBJECT' ) ;
|
||||
|
||||
foreach ( $fields as $index => $field ){
|
||||
if ( $field->get_field_type_object()->get_core() && $field->get_field_type_object()->get_related_mapped_prop() == 'title') {
|
||||
$core_title = $field;
|
||||
}
|
||||
if ( $field->get_field_type_object()->get_core() && $field->get_field_type_object()->get_related_mapped_prop() == 'description') {
|
||||
$core_description = $field;
|
||||
}
|
||||
}
|
||||
|
||||
$core_title->set_multiple('yes');
|
||||
$core_description->set_multiple('yes');
|
||||
|
||||
$this->assertFalse($core_title->validate(), 'Core metadata should not validate because it can not allow it to have multiple');
|
||||
$this->assertFalse($core_description->validate(), 'Core metadata should not validate because it can not allow it to have multiple');
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue