diff --git a/code/Control/UserDefinedFormAdmin.php b/code/Control/UserDefinedFormAdmin.php index 69241d3f..12a3786e 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\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..0349502a 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\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 95% rename from code/Form/UserFormsRequiredFields.php rename to code/Form/UserFormsRequiredFieldsValidator.php index 711dd273..fddba83a 100644 --- a/code/Form/UserFormsRequiredFields.php +++ b/code/Form/UserFormsRequiredFieldsValidator.php @@ -6,12 +6,12 @@ use SilverStripe\Dev\Debug; use SilverStripe\Forms\FileField; use SilverStripe\Forms\FormField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Core\ArrayLib; use SilverStripe\UserForms\Model\EditableFormField; /** - * 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. @@ -20,7 +20,7 @@ * Required fields will be validated as usual. * Conditionally required fields will be validated IF the display rules are satisfied in the submitted dataset. */ -class UserFormsRequiredFields extends RequiredFields +class UserFormsRequiredFieldsValidator extends RequiredFieldsValidator { /** * Allows validation of fields via specification of a php function for diff --git a/code/Model/EditableFormField/Validator.php b/code/Model/EditableFormField/Validator.php index ddcf691d..8c061a63 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\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/UserFormsRequiredFieldsTest.php index 9b45f96d..0febbcc9 100644 --- a/tests/php/Form/UserFormsRequiredFieldsTest.php +++ b/tests/php/Form/UserFormsRequiredFieldsTest.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()