DataForm

Category 1  Category 2  Category 3  Category 4  Category 5  



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::lists('firstname''id')->all());

        
//belongs to many (field name must be the relation name)
        
$form->add('categories','Categories','checkboxgroup')->options(Category::lists('name''id')->all());
        
$form->add('photo','Photo''image')->move('uploads/demo/')->fit(240160)->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