You need to make a custom hook so it checks the values of the FormIt fields to see if they equal the default values so it prevents the form from submitting.
Create a new snippet and call it: checkDefaultValues
Then paste this code.
<?php
$name = $hook->getValue('name');
$email = $hook->getValue('email';);
$time = $hook->getValue('time';);
$date = $hook->getValue('date';);
if( $name == 'Your name...'){
$errorMsg = 'Please enter your name';
$hook->addError('name',$errorMsg);
return false;
}else{
return true;
}
if( $email == 'Your email...'){
$errorMsg = 'Please enter an email';
$hook->addError('email',$errorMsg);
return false;
}else{
return true;
}
if( $time == 'Time of reservation...'){
$errorMsg = 'Please enter a time';
$hook->addError('time',$errorMsg);
return false;
}else{
return true;
}
if( $date == 'Date...'){
$errorMsg = 'Please enter a date';
$hook->addError('date',$errorMsg);
return false;
}else{
return true;
}
Then in your FormIt &hooks call add the custom hook before email since you want it to check the default values first before the other hooks.
&hooks=`checkDefaultValues, email,redirect`
This should work I'm not a PHP guru so I'm sure the code could be optimize but it will work for what you want it to do.
You can also use a preHook so it inserts the default values when rendering the form instead of hard coding them.
Hope that helps.
[ed. note: benmarte last edited this post 14 years, 1 month ago.]