required = array(
'form_name',
'form_street',
'form_place',
'form_pets',
'form_yesno'
);
// Set regex patterns to match fields against
$form->pattern = array(
'form_name' => '!^[a-zA-Z]+$!',
'form_street' => '!^([a-zA-Z])+( )?(\d{1,4}[a-zA-Z])?$!',
'form_place' => '!^[a-zA-Z]+$!'
);
/* Step 2 (optional): Create some dynamic fields (i.e. shopping cart) */
// Set dynamicaly generated fields to be required. Field name MUST start with 'dyn-'
for ( $i = 0; $i <= 2; $i++ ) {
array_push( $form->required, 'dyn-form_name-' . $i );
}
// Set patterns for dynamicaly generated fields
$pattern_dyn = array();
for ( $i = 0; $i <= 2; $i++ ) {
$pattern_dyn[ 'dyn-form_name-' . $i ] = '!^[a-zA-Z]+$!';
}
$form->pattern = array_merge( $form->pattern, $pattern_dyn );
/* Step 3: Process user input */
// Form sent?
if ( ! empty( $_POST ) )
$form->process( $_POST );
// Get the processed data
if ( isset( $form->processed_data ) )
echo 'Processed Data:
' . print_r( $form->processed_data, TRUE ) . '
';
// Include your form template or your form building function here.
else
include ( PLUGINDIR . '/300form/examples/template.php' );
?>