Salut
Je suis le cours de ZendFramework présenté sur le site j'ai mis une capture d'écran en pièce jointe et voilà mon code :
IndexController.php :
FormulaireAlbum.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 <?php public function modifierAction() { $this->view->title = "Modifier un album"; $form = new FormulaireAlbum(); $form->submit->setLabel('Enregistrer'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost() ; if ($form->isValid($formData)) { $albums = new Albums(); $id = (int)$form->getValue('id'); $row = $albums->fetchRow('id='.$id); $row->artist = $form->getValue('artist'); $row->title = $form->getValue('title'); $row->save(); $this->_redirect('/'); } else { $form->populate($formData); } } else { $id = (int)$this->_request->getParam('id', 0); if ($id > 0) { $albums = new Albums(); $album = $albums->fetchRow('id='.$id); $form->populate($album->toArray()); } } }
Pour l'action Ajouter ca marche mais quand j'essaye de modifier via "Edit" j'ai ces deux Grosses erreurs en GRAS
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 <?php class FormulaireAlbum extends Zend_Form { public function __construct($options = null) { parent::__construct($options); $this->setName('album'); $id = new Zend_Form_Element_Hidden('id'); $artist = new Zend_Form_Element_Text('artist'); $artist->setLabel('Artist') ->setRequired(true) ->addFilter('StripTags') ->addFilter('StringTrim') ->addValidator('NotEmpty'); $title = new Zend_Form_Element_Text('title'); $title->setLabel('Title') ->setRequired(true) ->addFilter('StripTags') ->addFilter('StringTrim') ->addValidator('NotEmpty'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $this->addElements(array($id, $artist, $title, $submit)); } }
quelqu'un pourrait-il me sauver la vieWarning: Missing argument 1 for Zend_View_Helper_Form::form() in /opt/lampp/htdocs/zf-tutorial/library/Zend/View/Helper/Form.php on line 44
Notice: Undefined variable: name in /opt/lampp/htdocs/zf-tutorial/library/Zend/View/Helper/Form.php on line 46
Merci d'avance![]()
Partager