dev-master
9999999-devForm component for Palmtree PHP
MIT
The Requires
by Andy Palmer
by andyexeter
0.5.1
0.5.1.0Form component for Palmtree PHP
MIT
The Requires
by andyexeter
Wallogit.com
2017 © Pedro Peláez
Form component for Palmtree PHP
PHP form builder with Bootstrap classes, validation, data binding, Google Recaptcha and hCaptcha support, plus other goodies., (*2)
Use composer to add the package to your dependencies:, (*3)
composer require palmtree/form
Optional: Install the NPM package for AJAX form submission, CAPTCHA support and form collections:, (*4)
npm install @palmtree/form
use Palmtree\Form\FormBuilder;
use Palmtree\Form\Captcha\GoogleRecaptcha;
use Palmtree\Form\Captcha\HCaptcha;
$builder = (new FormBuilder('my_form'))
->add('name', 'text', ['error_message' => 'Please enter your name'])
->add('email_address', 'email', [
'help' => 'We will never share your email with anyone',
])
->add('message', 'textarea', [
'required' => false,
'label' => 'Enter your message',
])
->add('recaptcha', 'captcha', [
'captcha' => new GoogleRecaptcha('<site_key>', '<secret>'),
//'captcha' => new HCaptcha('<site_key>', '<secret>'),
]);
$builder->add('send_message', 'submit');
$form = $builder->getForm();
// Set $form to some variable accessible in a view
= $form->render(); ?>
$form->handleRequest();
if ($form->isSubmitted() && $form->isValid()) {
// Send an email/save to database etc
$name = $form->get('name')->getData();
}
See the examples directory for examples using AJAX, file uploads, collections and more., (*5)
View the documentation for more advanced usage., (*6)
The simplest way to run the examples is run the serve.sh script. This script starts a small PHP Docker container and serves the examples using PHP's built-in web server., (*7)
./examples/serve.sh
Released under the MIT license, (*8)
Form component for Palmtree PHP
MIT
Form component for Palmtree PHP
MIT