This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 297
Custom Form Layout
Felice Ostuni edited this page Sep 21, 2015
·
9 revisions
There is not only {{ $form }} to show a form, if you need to customize something: wrap fields, grouping elements etc.. Simply call build method:
...
$form->build();
view('article', compact('form'))
then in the view you can use something like this:
#article.blade.php
{!! $form->header !!}
{!! $form->message !!} <br />
@if(!$form->message)
<div class="row">
<div class="col-sm-4">
{!! $form->render('title') !!}
</div>
<div class="col-sm-8">
{!! $form->render('body') !!}
</div>
</div>
...
@endif
{!! $form->footer !!}
Attribute or method | Output or content |
---|---|
$form->header | form open and header buttons |
$form->footer | footer buttons and form close |
$form->message | show if present a succes/confirmation message |
$form->fields | array of fields (to do a @foreach) |
$form->field('fieldname') | field instance, used without property it show field output |
$form->render('fieldname') | build entire field in a single call (label, field, errors) |
$form->error | error string containing all errors |
..field('fieldname')->messages | array of error messages for current field |
..field('fieldname')->message | string with all error messages for current field |
..field('fieldname')->has_error | bool, true if field is not valid for current rule |
$form->open | form open (it's contained in "header") |
$form->close | form close (it's contained in "footer") |
$form->button_container | array of buttons (it's contained in both header & footer) |
A full demo http://www.rapyd.com/rapyd-demo/styledform
presentation
editing