1. Go to this page and download the library: Download form-manager/form-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
form-manager / form-manager example snippets
use FormManager\Factory as F;
// Create an input type="text" element
$name = F::text();
// Create the input with a label
$name = F::text('Please, introduce your name');
// Or with extra attributes
$name = F::text('Please, introduce your name', ['class' => 'name-field']);
// Add or remove attributes
$name->setAttribute('title', 'This is the name input');
$name->removeAttribute('class');
$name->setAttributes([
'
// Set global default error messages
F::setErrorMessages([
'} characters or less',
]);
$email = F::email();
// Set per-fied error messages
$email->setErrorMessages([
'email' => 'The email is not valid',
'rror = $email->getError();
// Print the first error message
echo $error;
// Iterate through all error messages
foreach ($error as $err) {
echo $err->getMessage();
}
// And add more symfony constraints
$ip = F::text();
$ip->addConstraint(new Constraints\Ip());
$validator = Validation::createValidatorBuilder()
->setTranslator($translator)
->setTranslationDomain('validators')
->getValidator();
// Set validator
F::setValidator($validator);
$name = F::text('What is your name?', ['name' => 'name']);
echo $name;