email()->validate('user-email');
// check for errors
if ($validator->hasErrors()) {
$_SESSION['errors']['booking-form'] = $validator->getAllErrors();
} else {
$emailConfig = array(
'sender_email' => 'contact@phpformbuilder.pro',
'sender_name' => 'Php Form Builder',
'recipient_email' => addslashes($_POST['user-email']),
'subject' => 'Php Form Builder - Booking Form',
'filter_values' => 'booking-form, date_submit, time_submit',
'debug' => true
);
$sentMessage = Form::sendMail($emailConfig);
Form::clear('booking-form');
}
}
/* ==================================================
The Form
================================================== */
$form = new Form('booking-form', 'horizontal', 'novalidate', 'bs5');
$form->setMode('development');
$form->startFieldset('Please fill the form below', '', 'class=text-center mb-4');
$form->setCols(4, 4);
$form->groupElements('first-name', 'last-name');
$form->addHelper('First name', 'first-name');
$form->addInput('text', 'first-name', '', 'Full Name : ', 'required');
$form->setCols(0, 4);
$form->addHelper('Last name', 'last-name');
$form->addInput('text', 'last-name', '', '', 'required');
$form->setCols(4, 8);
$form->addInput('email', 'user-email', '', 'E-Mail : ', 'required');
$form->addHelper('Enter a valid phone number', 'phone-number');
$form->addInput('tel', 'user-phone', '', 'Phone Number : ', 'data-intphone=true, data-fv-intphonenumber=true, required');
$form->addInput('number', 'number-of-guests', '', 'Number of Guests: : ', 'data-fv-integer, required');
$form->setCols(4, 5);
$form->groupElements('date', 'time');
$form->addHelper('Date', 'date');
$form->addInput('text', 'date', '', 'Date / Time: ', 'data-litepick=true, data-min-date=' . date('Y-m-d') . ', required');
$form->setCols(0, 3);
$form->addHelper('Time', 'time');
$form->addTimeSelect('time', '', 'data-slimselect=true, data-show-search=false, data-allow-deselect=false, required', ['min' => '10:00', 'max' => '18:30', 'step' => 15]);
$form->setCols(4, 8);
$form->addOption('reservation-type', 'Dinner', 'Dinner', '', 'data-icon=bi bi-lamp-fill me-2');
$form->addOption('reservation-type', 'Birthday/ Anniversary', 'Birthday/ Anniversary', '', 'data-icon=bi bi-gift me-2');
$form->addOption('reservation-type', 'Nightlife', 'Nightlife', '', 'data-icon=bi bi-moon-stars me-2');
$form->addOption('reservation-type', 'Private', 'Private', '', 'data-icon=bi bi-lock-fill me-2');
$form->addOption('reservation-type', 'Wedding', 'Wedding', '', 'data-icon=bi bi-heart-fill me-2');
$form->addOption('reservation-type', 'Corporate', 'Corporate', '', 'data-icon=bi bi-briefcase-fill me-2');
$form->addOption('reservation-type', 'Other', 'Other', '', 'data-icon=bi bi-star-fill me-2');
$form->addSelect('reservation-type', 'Reservation Type', 'data-slimselect=true, data-show-search=false, data-allow-deselect=false, required');
$form->startDependentFields('reservation-type', 'Other');
$form->addInput('text', 'reservation-type-other', '', '', 'placeholder=Please tell more ..., required');
$form->endDependentFields();
$form->addTextarea('special-request', '', 'Any Special Request?', 'rows=7');
$form->centerContent();
$form->addBtn('submit', 'submit-btn', 1, 'Submit
', 'class=btn btn-primary, data-ladda-button=true, data-style=zoom-in');
$form->endFieldset();
// Javascript validation
// $form->addPlugin('formvalidation', '#booking-form');
?>
Bootstrap 5 Booking Form - How to create PHP forms easily
printIncludes('css'); ?>
Php Form Builder - Bootstrap 5 Booking Form
printIncludes('js');
$form->printJsCode();
?>