class DemoController extends Controller
....
public function anyForm()
{
$form = \DataForm::source(Article::find(1));
$form->add('title','Title', 'text')->rule('required|min:5');
$form->add('body','Body', 'redactor');
//belongs to
$form->add('author_id','Author','select')->options(Author::pluck('firstname', 'id')->all());
//belongs to many (field name must be the relation name)
$form->add('categories','Categories','checkboxgroup')->options(Category::pluck('name', 'id')->all());
$form->add('photo','Photo', 'image')->move('uploads/demo/')->fit(240, 160)->preview(120,80);
$form->add('color','Color','colorpicker');
$form->add('public','Public','checkbox');
$form->submit('Save');
$form->saved(function () use ($form) {
$form->message("ok record saved");
$form->link("/rapyd-demo/form","back to the form");
});
return view('rapyd::demo.form', compact('form'));
}
@extends('rapyd::demo.demo')
@section('title','DataForm')
@section('body')
@include('rapyd::demo.menu_form')
<h1>DataForm</h1>
<p>
{!! $form !!}
</p>
@stop