示例#1
0
 public function anyEdit()
 {
     if (Input::get('do_delete') == 1) {
         return "not the first";
     }
     $edit = DataEdit::source(new Article());
     $edit->link("rapyd-demo/filter", "Articles", "TR");
     $edit->add('title', 'Title', 'text')->rule('required|min:5');
     $edit->add('body', 'Body', 'textarea');
     $edit->add('author_id', 'Author', 'select')->options(Author::lists("firstname", "user_id"));
     $edit->add('public', 'Public', 'checkbox');
     $edit->add('categories', 'Categories', 'checkboxgroup')->options(Category::lists("name", "category_id"));
     return $edit->view('rapyd::demo.edit', compact('edit'));
 }
 public function getCategorylist()
 {
     //needed only if you want a custom remote ajax call for a custom search
     return Category::where("name", "like", Input::get("q") . "%")->take(10)->get();
 }
 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'));
 }