public function indexAction() { $ds = $this->set->createBuilder(); $ds->setSource(Article::with("comments", "author")); $ds->setPagination(5); $ds->getSet(); $this->render('Set', array('ds' => $ds)); }
public function indexAction() { //dataset widget $dg = $this->grid->createBuilder(); $dg->setSource(Article::with("author")); $dg->setPagination(10); $dg->add('article_id', "ID", true); $dg->add('title', "title"); $dg->add('<em>{{ article.author.firstname|lower }}</em>', "author"); $dg->getGrid(); $this->render('Grid', array('dg' => $dg)); }
public function indexAction() { //fill form data using a model $article = Article::find(1); $form = $this->form->createBuilder(); $form->add('title', 'text', array('constraints' => array(new NotBlank(), new Length(array('min' => 4))), 'attr' => array('placeholder' => 'article title'))); $form->add('body', 'textarea', array('constraints' => array(new NotBlank()))); $form->add('public', 'checkbox', array('required' => false)); $form->add('save', 'submit'); $form->setData($article->attributesToArray()); $form = $form->getForm(); //there is a post? if ($this->app->request()->post($form->getName())) { $form->bind($this->app->request()->post($form->getName())); if ($form->isValid()) { //bind model with new values and save $article->setRawAttributes($form->getData()); $article->save(); } } $this->render('Form', array('testform' => $form->createView())); }
public function indexAction() { //get first article using an eloquent model $article = Article::with("author")->find(1); $this->render('Eloquent', array('article' => $article)); }