enjoys/bootstrap4-renderer

Renderer for enjoys/forms

2.0.0 2024-05-03 12:27 UTC

This package is auto-updated.

Last update: 2024-11-03 16:06:51 UTC


README

Renderer for enjoys/forms

Run built-in server for view example

port=$(shuf -i 2048-65000 -n 1);
php -S localhost:"${port}" -t ./example .route

Usage

use Enjoys\Forms\Renderer\Bootstrap4\Bootstrap4Renderer;
use Enjoys\Forms\Form;
$renderer = new Bootstrap4Renderer();
/** @var Form $form */
$renderer->setForm($form);
$renderer->output();

or

use Enjoys\Forms\Renderer\Bootstrap4\Bootstrap4Renderer;
use Enjoys\Forms\Form;
/** @var Form $form */
$renderer = new Bootstrap4Renderer($form);
$renderer->output();

Options

switch setting for the checkbox elements the custom switch control

see https://getbootstrap.com/docs/4.6/components/forms/#switches

setting for all the checkbox elements the custom switch

$renderer->setOptions([
    'switch' => true 
]);

setting for one element the custom switch

$renderer->setOptions([
    'switch' => 'element_name'
]);

setting a custom switch for the listed elements

$renderer->setOptions([
    'switch' => [
        'element_name', 
        'more_element', 
        //...
    ] 
]);