diff --git a/code/Control/UserDefinedFormAdmin.php b/code/Control/UserDefinedFormAdmin.php index e44e0430..3451d57d 100644 --- a/code/Control/UserDefinedFormAdmin.php +++ b/code/Control/UserDefinedFormAdmin.php @@ -13,7 +13,7 @@ use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\OptionsetField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\Schema\FormSchema; use SilverStripe\Forms\TextField; use SilverStripe\Forms\TreeDropdownField; @@ -192,7 +192,7 @@ private function buildConfirmFolderForm(string $suggestedFolderName = '', string ->setUseButtonTag(true) ); - return Form::create($this, 'ConfirmFolderForm', $fields, $actions, RequiredFields::create('ID')) + return Form::create($this, 'ConfirmFolderForm', $fields, $actions, RequiredFieldsValidator::create('ID')) ->setFormAction($this->Link('ConfirmFolderForm')) ->addExtraClass('form--no-dividers'); } diff --git a/code/Extension/UserFormValidator.php b/code/Extension/UserFormValidator.php index ba327101..2e6c4091 100644 --- a/code/Extension/UserFormValidator.php +++ b/code/Extension/UserFormValidator.php @@ -2,13 +2,13 @@ namespace SilverStripe\UserForms\Extension; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup; use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroupEnd; use SilverStripe\UserForms\Model\EditableFormField; use SilverStripe\UserForms\Model\EditableFormField\EditableFormStep; -class UserFormValidator extends RequiredFields +class UserFormValidator extends RequiredFieldsValidator { public function php($data) { diff --git a/code/Form/UserForm.php b/code/Form/UserForm.php index a9b73e08..034f194b 100644 --- a/code/Form/UserForm.php +++ b/code/Form/UserForm.php @@ -160,7 +160,7 @@ public function getFormActions() /** * Get the required form fields for this form. * - * @return RequiredFields + * @return RequiredFieldsValidator */ public function getRequiredFields() { @@ -172,7 +172,7 @@ public function getRequiredFields() ->filter('Required', true) ->column('Name'); $requiredNames = array_merge($requiredNames, $this->getEmailRecipientRequiredFields()); - $required = UserFormsRequiredFields::create($requiredNames); + $required = UserFormsRequiredFieldsValidator::create($requiredNames); $this->extend('updateRequiredFields', $required); $required->setForm($this); return $required; @@ -203,7 +203,7 @@ public function getButtonText() } /** - * Push fields into the RequiredFields array if they are used by any Email recipients. + * Push fields into the RequiredFieldsValidator array if they are used by any Email recipients. * Ignore if there is a backup i.e. the plain string field is set * * @return array required fields names diff --git a/code/Form/UserFormsRequiredFields.php b/code/Form/UserFormsRequiredFieldsValidator.php similarity index 94% rename from code/Form/UserFormsRequiredFields.php rename to code/Form/UserFormsRequiredFieldsValidator.php index d0ab8604..4764f793 100644 --- a/code/Form/UserFormsRequiredFields.php +++ b/code/Form/UserFormsRequiredFieldsValidator.php @@ -6,13 +6,13 @@ use SilverStripe\Dev\Debug; use SilverStripe\Forms\FileField; use SilverStripe\Forms\FormField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Core\ArrayLib; use SilverStripe\UserForms\Model\EditableFormField; use SilverStripe\Dev\Deprecation; /** - * An extension of RequiredFields which handles conditionally required fields. + * An extension of RequiredFieldsValidator which handles conditionally required fields. * * A conditionally required is a field that is required, but can be hidden by display rules. * When it is visible, (according to the submitted form data) it will be validated as required. @@ -23,7 +23,7 @@ * * @deprecated 5.4.0 Will be renamed to SilverStripe\UserForms\Form\UserFormsRequiredFieldsValidator */ -class UserFormsRequiredFields extends RequiredFields +class UserFormsRequiredFieldsValidator extends RequiredFieldsValidator { public function __construct() { @@ -108,7 +108,7 @@ private function getEditableFormFieldByName($name) /** * Check if the validation rules for the specified field are met by the provided data. * - * @note Logic replicated from php() method of parent class `SilverStripe\Forms\RequiredFields` + * @note Logic replicated from php() method of parent class `SilverStripe\Forms\Validation\RequiredFieldsValidator` * @param EditableFormField $field * @param array $data * @return bool diff --git a/code/Model/EditableFormField/Validator.php b/code/Model/EditableFormField/Validator.php index ddcf691d..3fbaaa57 100644 --- a/code/Model/EditableFormField/Validator.php +++ b/code/Model/EditableFormField/Validator.php @@ -2,10 +2,10 @@ namespace SilverStripe\UserForms\Model\EditableFormField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\UserForms\Model\EditableFormField; -class Validator extends RequiredFields +class Validator extends RequiredFieldsValidator { /** * diff --git a/tests/php/Form/UserFormsRequiredFieldsTest.php b/tests/php/Form/UserFormsRequiredFieldsValidatorTest.php similarity index 94% rename from tests/php/Form/UserFormsRequiredFieldsTest.php rename to tests/php/Form/UserFormsRequiredFieldsValidatorTest.php index 9b45f96d..0febbcc9 100644 --- a/tests/php/Form/UserFormsRequiredFieldsTest.php +++ b/tests/php/Form/UserFormsRequiredFieldsValidatorTest.php @@ -5,12 +5,12 @@ use SilverStripe\CMS\Controllers\ModelAsController; use SilverStripe\Dev\Debug; use SilverStripe\Dev\SapphireTest; -use SilverStripe\UserForms\Form\UserFormsRequiredFields; +use SilverStripe\UserForms\Form\UserFormsRequiredFieldsValidator; use SilverStripe\UserForms\Model\UserDefinedForm; use SilverStripe\UserForms\Form\UserForm; use PHPUnit\Framework\Attributes\DataProvider; -class UserFormsRequiredFieldsTest extends SapphireTest +class UserFormsRequiredFieldsValidatorTest extends SapphireTest { protected static $fixture_file = '../UserFormsTest.yml'; @@ -21,13 +21,13 @@ private function getValidatorFromPage($page) return $form->getValidator(); } - public function testUsesUserFormsRequiredFieldsValidator() + public function testUsesUserFormsRequiredFormFieldsValidator() { $page = $this->objFromFixture(UserDefinedForm::class, 'required-custom-rules-form'); $this->assertEquals(3, $page->Fields()->count()); $validator = $this->getValidatorFromPage($page); $this->assertNotNull($validator); - $this->assertInstanceOf(UserFormsRequiredFields::class, $validator, 'Uses UserFormsRequiredFields validator'); + $this->assertInstanceOf(UserFormsRequiredFieldsValidator::class, $validator, 'Uses UserFormsRequiredFieldsValidator validator'); } public static function dataProviderValidationOfConditionalRequiredFields()