Formulaire : création de manière générique
[zf2.biz/galerie.git] / module / Galerie / src / Galerie / Form / GalerieForm.php
index 02107cd..a5fbcea 100644 (file)
@@ -2,50 +2,38 @@
 
 namespace Galerie\Form;
 
-use Zend\Form\Form;
+use Custom\Form\AbstractForm;
 
-class GalerieForm extends Form
+
+class GalerieForm extends AbstractForm
 {
 
-    public function __construct($name=null)
+    public function initialize()
     {
-        parent::__construct('galerie');
-        $this->setAttribute('method', 'post');
-        $this->add(array(
-            'name' => 'id',
-            'attributes' => array(
-                'type' => 'hidden',
-            ),
-        ));
-        $this->add(array(
-            'name' => 'name',
-            'attributes' => array(
-                'type' => 'text',
-            ),
-            'options' => array(
-                'label' => 'Name',
-            )
-        ));
-        $this->add(array(
-            'name' => 'description',
-            'attributes' => array(
-                'type' => 'text',
-            ),
-            'options' => array(
-                'label' => 'Description',
-            )
-        ));
-        $this->add(array(
-            'name' => 'submit',
-            'attributes' => array(
-                'type' => 'submit',
+        $elements = include __DIR__ . '/galerie.form.config.php';
+        $this->addElements($elements);
+        /* Méthode alternative
+        $this->setMethod('post');
+        $this->addElement('id', 'hidden');
+        $this->addElement(
+            'name',
+            'text',
+            $this->translate('Galerie_form_label_name')
+        );
+        $this->addElement(
+            'description',
+            'text',
+            $this->translate('Galerie_form_label_description')
+        );
+        $this->addElement(
+            'submit',
+            'submit',
+            null,
+            array(
                 'value' => 'Valider',
                 'id' => 'submit_galerie_form',
-            ),
-            'options' => array(
-                'label' => 'Description',
             )
-        ));
+        );*/
     }
 
 }