Jump to content

Custom fields. Registration.Toggles

Go to solution Solved by bfarber,

Recommended Posts


I'm trying to add the toggles to built-in custom fields

All works fine on the edit profile page

But doesn't work on the registration page


						if( $field->required and ( $values[ $field->name ] === NULL or !isset( $values[ $field->name ] ) ) )
							\IPS\Output::i()->error( 'reg_required_fields', '1C223/5', 403, '' );

Any reason why you have added that code?


Link to comment
Share on other sites

15 hours ago, bfarber said:

The code would appear to be in place to ensure fields required for registration are filled in.

It should do the Form helper



					/* If this is dependant on a toggle which isn't set, don't return a value so that it doesn't
						trigger an error we cannot see */
					if ( $element->htmlId and \in_array( $element->htmlId, $htmlIdsToIgnore ) )
						$values[ $_name ] = $stringValues ? $element::stringValue( $element->defaultValue ) : $element->defaultValue;

So if the required field has been hidden by toggle we should not get an error.

15 hours ago, bfarber said:

If you removed that code, does everything work as you are expecting


Without toggles


The required fields validate by Helpers

With toggles


With toggles + I've removed 

							\IPS\Output::i()->error( 'reg_required_fields', '1C223/5', 403, '' );


With toggles. Required field not filled


Edited by newbie LAC
Link to comment
Share on other sites

  • 1 year later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...