示例#1
0
 public function anyAdvancedform()
 {
     $form = DataForm::source(Article::find(1));
     $form->add('title', 'Title', 'text')->rule('required|min:5');
     //simple autocomplete with local javascript array
     $form->add('author_id', 'Author', 'autocomplete')->options(Author::lists('firstname', 'user_id'));
     //autocomplete with relation.field,  array of search fields, foreign key
     $form->add('author.fullname', 'Author', 'autocomplete')->remote(array("firstname", "lastname"), "user_id");
     //autocomplete with relation.field,  array of search fields, foreign key, but with  custom  remote url / method
     $form->add('author.firstname', 'Author', 'autocomplete')->remote(null, "user_id", "/rapyd-demo/authorlist");
     $form->submit('Save');
     $form->saved(function () use($form) {
         $form->message("ok record saved");
         $form->link("/rapyd-demo/advancedform", "back to the form");
     });
     return View::make('rapyd::demo.advancedform', compact('form'));
 }
 public function anyStyledform()
 {
     $form = DataForm::source(Article::find(1));
     $form->add('title', 'Title', 'text')->rule('required|min:5');
     $form->add('body', 'Body', 'redactor');
     $form->add('categories.name', 'Categories', 'tags');
     $form->add('photo', 'Photo', 'image')->move('uploads/demo/')->fit(240, 160)->preview(120, 80);
     $form->submit('Save');
     $form->saved(function () use($form) {
         $form->message("ok record saved");
         $form->link("/rapyd-demo/styledform", "back to the form");
     });
     $form->build();
     return View::make('rapyd::demo.styledform', compact('form'));
 }
 public function anyForm()
 {
     $form = DataForm::source(Article::find(37));
     $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'));
     //belongs to many (field name must be the relation name)
     $form->add('categories', 'Categories', 'checkboxgroup')->options(Category::lists('name', 'id'));
     //$form->add('photo','Photo', 'image')->moveDeferred('uploads/demo/{{ $id }}')->fit(210, 160)->preview(120,80);
     $form->add('detail.note', 'Note', 'file')->moveDeferred('uploads/demo/{{ $id }}');
     $form->add('public', 'Public', 'checkbox');
     $form->submit('Save');
     $form->saved(function () use($form) {
         $form->message("ok record saved");
         $form->link("/test/form", "back to the form");
     });
     return View::make('rapyd::demo.form', compact('form'));
 }