goldmorphin Posted August 2, 2018 Posted August 2, 2018 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' ),
bfarber Posted August 2, 2018 Posted August 2, 2018 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 }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.