From ba7ded5c1bd9868fd7550913dca89396c2591187 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 20 May 2020 15:57:33 -0400 Subject: [PATCH] PriceFieldValue - Make name and label required in DB --- CRM/Core/I18n/SchemaStructure.php | 2 +- .../PriceFieldValueCreationSpecProvider.php | 41 +++++++++++++++++++ xml/schema/Price/PriceFieldValue.xml | 2 + 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Civi/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php diff --git a/CRM/Core/I18n/SchemaStructure.php b/CRM/Core/I18n/SchemaStructure.php index c76ece1754..2891b58c07 100644 --- a/CRM/Core/I18n/SchemaStructure.php +++ b/CRM/Core/I18n/SchemaStructure.php @@ -154,7 +154,7 @@ class CRM_Core_I18n_SchemaStructure { 'help_post' => "text COMMENT 'Description and/or help text to display after this field.'", ], 'civicrm_price_field_value' => [ - 'label' => "varchar(255) COMMENT 'Price field option label'", + 'label' => "varchar(255) NOT NULL COMMENT 'Price field option label'", 'description' => "text DEFAULT NULL COMMENT 'Price field option description.'", 'help_pre' => "text DEFAULT NULL COMMENT 'Price field option pre help text.'", 'help_post' => "text DEFAULT NULL COMMENT 'Price field option post field help.'", diff --git a/Civi/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php b/Civi/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php new file mode 100644 index 0000000000..00c6b19d1e --- /dev/null +++ b/Civi/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php @@ -0,0 +1,41 @@ +getFieldByName('name')->setRequired(FALSE); + } + + /** + * @inheritDoc + */ + public function applies($entity, $action) { + return $entity === 'PriceFieldValue' && $action === 'create'; + } + +} diff --git a/xml/schema/Price/PriceFieldValue.xml b/xml/schema/Price/PriceFieldValue.xml index 2740ab2e64..74c649b916 100644 --- a/xml/schema/Price/PriceFieldValue.xml +++ b/xml/schema/Price/PriceFieldValue.xml @@ -37,6 +37,7 @@ Name 255 Price field option name + true Text @@ -49,6 +50,7 @@ 255 true Price field option label + true Text -- 2.25.1