public function configForm() { $config = $this->config; $adminPosts = new Input(array('type' => 'text', 'name' => 'postsAdmin', 'label' => 'Nombre de posts/utilisateurs sur l\'index de l\'Administration :', 'value' => strval($config->postsperpage->admin), 'attributes' => 'class="form-control" required')); $blogPosts = new Input(array('type' => 'text', 'name' => 'postsBlog', 'label' => 'Nombre de posts/utilisateurs sur l\'index du Blog :', 'value' => strval($config->postsperpage->blog), 'attributes' => 'class="form-control" required')); $modComs = new Input(array('type' => 'checkbox', 'name' => 'moderateComs', 'value' => '1', 'label' => 'Modérer les commentaires Avant publication :')); if ($config->moderate_comments == true) { $modComs->setAttributes('class="form-control" checked'); } else { $modComs->setAttributes('class="form-control"'); } $submit = new Input(array('type' => 'submit', 'name' => 'submit', 'value' => 'Sauvegarder', 'attributes' => 'class="btn btn-primary"')); $form = new FormType(array('action' => '/admin/config/save', 'method' => 'post', 'attributes' => 'class="well" id="configForm"')); $form->addField($adminPosts); $form->addField($blogPosts); $form->addField($modComs); $form->addField($submit); $content = '<h3>Page de configuration</h3>'; $content .= $form->createView(); return $this->getPage($content); }
public function postForm($post = null) { $title = new Input(array('type' => 'text', 'name' => 'title', 'label' => 'Titre de l\'article :', 'attributes' => 'class="form-control" required')); $author = new Input(array('type' => 'text', 'name' => 'author', 'label' => 'Auteur :', 'attributes' => 'class="form-control"', 'value' => $_SESSION['username'])); $content = new Textarea(array('name' => 'content', 'label' => 'Contenu :', 'attributes' => 'rows="10" class="form-control" id="content" required')); $submit = new Input(array('type' => 'submit', 'name' => 'submit', 'value' => 'Enregistrer', 'attributes' => 'class="btn btn-primary"')); if (!is_null($post)) { $title->setValue($post[0]->getTitle()); $author->setValue($post[0]->getAuthor()); $content->setPlaceholder($post[0]->getContent()); } $form = new FormType(array('action' => '/admin/post/save', 'method' => 'post', 'attributes' => 'class="well"')); $form->addField($title); $form->addField($author); $form->addField($content); $form->addField($submit); if (!is_null($post)) { $content = '<h3>Editer un post :</h3>'; } else { $content = '<h3>Nouveau post :</h3>'; } $content .= $form->createView(); return $this->getPage($content); }