/** Edit a material type
  */
 public function editmaterialAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new MaterialForm();
         $form->submit->setLabel(self::UPDATE);
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $materials = new Materials();
                 $where = array();
                 $where[] = $materials->getAdapter()->quoteInto('id = ?', (int) $this->_getParam('id'));
                 $update = $materials->update($form->getValues(), $where);
                 $this->_flashMessenger->addMessage('Material information updated!');
                 $this->_redirect($this->_redirectUrl . 'materials');
             } else {
                 $form->populate($form->getValues());
             }
         } else {
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $materials = new Materials();
                 $material = $materials->fetchRow('id=' . $id);
                 if (count($material)) {
                     $form->populate($material->toArray());
                 } else {
                     throw new Pas_Exception_Param($this->_nothingFound);
                 }
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }
Example #2
0
  
  echo $form->inputText("Nom", "name", "text");
  
  echo $form->inputText("Email", "email", "email");
  
  echo $form->inputText("Password", "password", "password");
  
  echo $form->inputText("Tel", "phone", "text");
  $options = [
      "h" => "Homme",
      "f" => "Femme"
  ];
  echo $form->inputSelect("Genre", "genre", $options );
  echo $form->submit("OK");
  echo $form->closeFieldSet();
  echo $form->closeForm();*/
require_once 'MaterialForm.class.php';
var_dump($_POST);
$form = new MaterialForm($_POST);
$form->valid();
echo $form->openForm('index.php', 'post', 12);
echo $form->inputText("Nom", "name", "text");
echo $form->submit("OK");
echo $form->closeForm();
?>
    
    </div>
    <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>
</body>
</html>