1. Go to this page and download the library: Download webservco/form 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/ */
webservco / form example snippets
use Fig\Http\Message\StatusCodeInterface;
use WebServCo\Form\Service\Filter\StripTagsFilter;
use WebServCo\Form\Service\Filter\TrimFilter;
use WebServCo\Form\Service\FormField;
use WebServCo\Form\Service\HtmlPostForm;
use WebServCo\Form\Service\Validator\MaximumLengthValidator;
use WebServCo\Form\Service\Validator\RequiredValidator;
// \WebServCo\Form\Contract\FormInterface
$form = new HtmlPostForm(
[
new FormField(
// Field filters.
[],
// id: the POST key.
'name',
// Required.
true,
// name, placeholder, title
'name',
'Item name',
'Name',
// Field validators.
[new MaximumLengthValidator(new Error('Maximum length: 90 chars.', StatusCodeInterface::STATUS_BAD_REQUEST), 90)],
// Initial value.
null,
),
],
// Filters for every field.
[new TrimFilter(), new StripTagsFilter()],
// Validators for every field.
[new RequiredValidator(new Error('Field is
$form->handleRequest($request);
if ($form->isSent() && $form->isValid()) {
$name = $form->getField('name')->getValue();
// Save, then redirect.
}
// Show the form again: 200 on first display, 422 when it has errors.
return $this->createResponse($request, $viewContainer, $form->getResponseStatusCode());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.