PHP code example of typicms / bootforms
1. Go to this page and download the library: Download typicms/bootforms 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/ */
typicms / bootforms example snippets
'providers' => [
//...
'TypiCMS\BootForms\BootFormsServiceProvider'
],
'aliases' => [
//...
'BootForm' => 'TypiCMS\BootForms\Facades\BootForm'
],
BootForm::text('Email', 'email');
$formBuilder = new TypiCMS\Form\FormBuilder;
$formBuilder->setOldInputProvider($myOldInputProvider);
$formBuilder->setErrorStore($myErrorStore);
$formBuilder->setToken($myCsrfToken);
$basicBootFormsBuilder = new TypiCMS\BootForms\BasicFormBuilder($formBuilder);
$horizontalBootFormsBuilder = new TypiCMS\BootForms\HorizontalFormBuilder($formBuilder);
$bootForm = new TypiCMS\BootForms\BootForm($basicBootFormsBuilder, $horizontalBootFormsBuilder);
// <form method="post">
// <div class="mb-3">
// <label for="field_name" class="form-label">Field Label</label>
// <input type="text" class="form-control" id="field_name" name="field_name">
// </div>
// </form>
{!! BootForm::open() !!}
{!! BootForm::text('Field Label', 'field_name') !!}
{!! BootForm::close() !!}
// <div class="mb-3">
// <label for="first_name" class="form-label">First Name</label>
// <input type="text" class="form-control" id="first_name" name="first_name" placeholder="John Doe">
// </div>
BootForm::text('First Name', 'first_name')->placeholder('John Doe');
// <div class="mb-3">
// <label for="color" class="form-label">Color</label>
// <select class="form-select" id="color" name="color">
// <option value="red">Red</option>
// <option value="green" selected>Green</option>
// </select>
// </div>
BootForm::select('Color', 'color')->options(['red' => 'Red', 'green' => 'Green'])->select('green');
// <form method="GET" action="/users">
BootForm::open()->get()->action('/users');
// <div class="mb-3">
// <label for="first_name" class="form-label">First Name</label>
// <input type="text" class="form-control" id="first_name" name="first_name" value="John Doe">
// </div>
BootForm::text('First Name', 'first_name')->defaultValue('John Doe');
{!! BootForm::open() !!}
{!! BootForm::text('First Name', 'first_name') !!}
{!! BootForm::text('Last Name', 'last_name') !!}
{!! BootForm::date('Date of Birth', 'date_of_birth') !!}
{!! BootForm::email('Email', 'email') !!}
{!! BootForm::password('Password', 'password') !!}
{!! BootForm::submit('Submit') !!}
{!! BootForm::close() !!}
// <div class="mb-3">
// <label for="amount" class="form-label">Amount</label>
// <div class="input-group">
// <span class="input-group-text">$</span>
// <input type="number" name="amount" id="amount" class="form-control">
// </div>
// </div>
{!! BootForm::inputGroup('Amount', 'amount')->type('number')->beforeAddon('<span class="input-group-text">$</span>') !!}
// <div class="mb-3">
// <label for="email">Email</label>
// <div class="input-group">
// <input type="text" name="email" id="email" class="form-control">
// <button type="submit" class="btn btn-primary">OK</button>
// </div>
// </div>
{!! BootForm::inputGroup('Email', 'email')->afterAddon(BootForm::submit('OK')) !!}
<div class="mb-3">
<label for="first_name" class="form-label">First Name</label>
<input type="text" class="form-control {!! $errors->has('first_name') ? 'is-invalid' : '' !!}" id="first_name">
{!! $errors->first('first_name', '<div class="invalid-feedback">:message</div>') !!}
</div>
{!! BootForm::text('First Name', 'first_name') !!}
// Width in columns of the left and right side
// for each breakpoint you’d like to specify.
$columnSizes = [
'sm' => [4, 8],
'lg' => [2, 10]
];
{!! BootForm::openHorizontal($columnSizes) !!}
{!! BootForm::text('First Name', 'first_name') !!}
{!! BootForm::text('Last Name', 'last_name') !!}
{!! BootForm::text('Date of Birth', 'date_of_birth') !!}
{!! BootForm::email('Email', 'email') !!}
{!! BootForm::password('Password', 'password') !!}
{!! BootForm::submit('Submit') !!}
{!! BootForm::close() !!}
BootForm::text('First Name', 'first_name')->hideLabel()
BootForm::text('Password', 'password')->formText('A strong password should be long and hard to guess.')
BootForm::open()->action(route('users.update', $user))->put()
BootForm::bind($user)
BootForm::close()