Package Data | |
---|---|
Maintainer Username: | jbravo |
Maintainer Contact: | nerd305@gmail.com (Mark Hilton) |
Package Create Date: | 2016-06-13 |
Package Last Update: | 2016-07-15 |
Language: | HTML |
License: | MIT |
Last Refreshed: | 2024-12-19 03:18:09 |
Package Statistics | |
---|---|
Total Downloads: | 116 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
FormFields is a collection of editable Laravel Blade views to render bootstrap responsive HTML content for individual form fields. The form configuration is fetched from ORM model.
It also contains a class to queue linked and inline supporting javascripts.
Add to your config/app.php
'providers' => [
...
MarkHilton\FormFields\FormFieldsServiceProvider::class,
],
'aliases' => [
...
'jsQueue' => MarkHilton\FormFields\jsQueue::class,
'FormBuilder' => MarkHilton\FormFields\FormBuilder::class,
],
inside app root folder copy config file:
cp vendors/markhilton/formfields/config/formfields.php configs/formfields.php
class Your_Model_Name extends Model
{
public static $errors = [];
// ... //
// HTML form builder definitions
public static $form = [
'name' => [
'type' => 'input',
'label' => 'Label name',
'position' => 'top',
],
'status' => [
'type' => 'select',
'label' => 'Status',
'position' => 'side',
'choice' => [
'active' => 'Active',
'pending' => 'Pending',
'suspended'=> 'Suspended',
],
'default' => 'active',
],
// ... //
namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Your_Model_Name;
use Illuminate\Http\Request;
class SiteController extends Controller {
public function create(Request $request)
{
$form = \FormBuilder::build(Your_Model_Name::$form, $request->old() ? $request->old() : []),
return view('layout', $form);
// ... //
<div class="row">
{{ $status }}
{{ $name }}
</div>
<div class="row">
<div>
<select id="field-status" class="width100p" name="status" data-placeholder="">
<option selected="selected" value="active">Active</option>
<option value="pending">Pending</option>
<option value="suspended">Suspended</option>
</select>
</div>
<div class="form-group">
<label class=" control-label">Name</label>
<div>
<input type="text" name="name" value="" class="form-control" />
</div>
</div>
</div>
Queue for linked and inline javascripts inside view template
add {{ jsQueue::render() }} call in template header or footer in order to render queued javascripts