Jump to content

Form validating


goldmorphin

Recommended Posts

Hello.

I find here that forms have validating methods. It's work for me, when i callback DomainException, but can i modify values instead callback DomainException?
I want replace "+" in $val on "".

'unitpay_qiwi' => new \IPS\Helpers\Form\Text( 'unitpay_qiwi', $phone, FALSE, NULL, function( $val )
					{
						if ( strpos($val, '+') !== false )
						{
							$val = str_replace('+', '', $val);
                    	}
					}, NULL, NULL, 'unitpay_qiwi' ),

 

Link to comment
Share on other sites

I'm afraid not. The form validation method is purely for validating the input value (and you should throw a DomainException if the value isn't valid).

If you need to adjust the value, you do that when collecting the form values.

// Create the form and add your objects
$form = new \IPS\Helpers\Form;
$form->add( ... /* assume key here is 'test' */ );

if( $values = $form->values() )
{
	$values['test'] = str_replace( '+', '', $values['test'] );

	// Now do whatever you need to with the values
}

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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