Provides helper objects for generating shared/forms that allow for validation on a per form basis.
Sometimes you just need a simple form that isn't related to any specific data model. This library provides that plus removes the burden of handling Validation of the data.
- ExpressionEngine >= 5.5
- PHP >= 7.1
Add ee-objects/forms as a requirement to your composer.json:
$ composer require ee-objects/formsOnce installed, the programmatic flow should be simple. Get the form, validate it, process it:
$form = new MyFormObject()
$defaults = [];
$vars = [];
$form->setData($this->settings->settings('cartthrob'));
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$form->setData($_POST);
$result = $form->validate($_POST);
if ($result->isValid()) {
//magic time
}
$vars['errors'] = $result;
}
$vars['sections'] = $form->generate();Available in the Wiki and the EeObjects Addon repository