Making a field not required

To make a field not required you need to remove the ‘required’ validator. Open process.php and find the PHP code for the element you want to change. There should be code that looks like the following:

1
$element->addValidator('required');
$element->addValidator('required');

In this case, simply removing this line will make the field no longer required. Note: instead of $element it will be the unique element name.

In some cases, the elements have been configured by adding multiple validators at once using an array as shown below.

1
$element->addValidators(array('required', 'email'));
$element->addValidators(array('required', 'email'));

Remove the 'required' string and the comma after it. The multiple validators line would now look like this:

1
$element->addValidators(array('email'));
$element->addValidators(array('email'));

It might also be a good idea to remove the asterisk from the element label on your web page to let users know that the field is no longer required.

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy