namespace Galerie\Form;
-use Zend\Form\Form;
+use Custom\Form\AbstractForm;
-use Zend\I18n\Translator\TranslatorAwareInterface;
-use Zend\I18n\Translator\Translator;
-
-class GalerieForm extends Form implements TranslatorAwareInterface
+class GalerieForm extends AbstractForm
{
- private $_translator;
- private $_textDomain = 'galerie';
- private $_translator_enabled = true;
-
-
public function initialize()
{
- $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' => $this->translate('Galerie_form_label_name'),
- )
- ));
- $this->add(array(
- 'name' => 'description',
- 'attributes' => array(
- 'type' => 'text',
- ),
- 'options' => array(
- 'label' => $this->translate('Galerie_form_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',
- ),
- ));
- }
-
-
-
-
- public function translate($k)
- {
- if ($this->_translator && $this->_translator_enabled) {
- return $this->_translator->translate($k, $this->_textDomain);
- }
- return $k . '(Non traduit)';
- }
-
-
- public function setTranslator(Translator $translator = null, $textDomain = null)
- {
- $this->_translator = $translator;
- $this->_textDomain = $textDomain;
- }
-
- public function getTranslator()
- {
- return $this->_translator;
- }
-
- public function hasTranslator()
- {
- return $this->_translator !== null;
- }
-
- public function setTranslatorEnabled($enabled = true)
- {
- $this->_translator_enabled = $enabed;
- }
-
- public function isTranslatorEnabled()
- {
- return $this->_translator_enabled;
- }
-
- public function setTranslatorTextDomain($textDomain = 'default')
- {
- $this->_textDomain = $textDomain;
- }
-
- public function getTranslatorTextDomain()
- {
- return $this->_textDomain;
+ )
+ );*/
}
}
--- /dev/null
+<?php
+return array(
+ array(
+ 'name' => 'id',
+ 'attributes' => array(
+ 'type' => 'hidden',
+ ),
+ ),
+ array(
+ 'name' => 'name',
+ 'attributes' => array(
+ 'type' => 'text',
+ ),
+ 'options' => array(
+ 'label' => $this->translate('Galerie_form_label_name'),
+ ),
+ ),
+ array(
+ 'name' => 'description',
+ 'attributes' => array(
+ 'type' => 'text',
+ ),
+ 'options' => array(
+ 'label' => $this->translate('Galerie_form_label_description'),
+ ),
+ ),
+ array(
+ 'name' => 'submit',
+ 'attributes' => array(
+ 'type' => 'submit',
+ 'value' => 'Valider',
+ 'id' => 'submit_galerie_form',
+ ),
+ ),
+);
namespace Galerie\Model;
-use Zend\InputFilter\Factory as InputFactory;
-use Zend\InputFilter\InputFilter;
-use Zend\InputFilter\InputFilterInterface;
-use Zend\InputFilter\InputFilterAwareInterface;
-
use Custom\Model\Entity;
-class Galerie extends Entity implements InputFilterAwareInterface
+class Galerie extends Entity
{
public $id;
public $id_user;
public $created;
public $updated;
- protected $inputFilter;
-
protected $columns = array(
'id',
'id',
);
- public function getArrayCopy()
- {
- return $this->toArray();
- }
-
- public function setInputFilter(InputFilterInterface $inputfilter)
- {
- throw new \Exception("This entity does not allow to set Input Filter");
- }
- public function getInputFilter()
+ public function getDefaultInputFilterArrays()
{
- if (!$this->inputFilter) {
- $inputFilter = new InputFilter;
- $factory = new InputFactory;
-
- $inputFilter->add($factory->createInput(array(
- 'name' => 'id',
- 'required' => true,
- 'filters' => array(
- array('name' => 'Int'),
- ),
- )));
-
- $inputFilter->add($factory->createInput(array(
- 'name' => 'name',
- 'required' => true,
- 'filters' => array(
- array('name' => 'StripTags'),
- array('name' => 'StringTrim'),
- ),
- 'validators' => array(
- array(
- 'name' => 'StringLength',
- 'options' => array(
- 'encoding' => 'UTF-8',
- 'min' => 1,
- 'max' => 32,
- ),
- ),
- ),
- )));
-
- $inputFilter->add($factory->createInput(array(
- 'name' => 'description',
- 'required' => true,
- 'filters' => array(
- array('name' => 'StripTags'),
- array('name' => 'StringTrim'),
- ),
- )));
-
- $this->inputFilter = $inputFilter;
- }
-
- return $this->inputFilter;
-
+ return include __DIR__ . '/galerie.defaultinputfilter.config.php';
}
}
--- /dev/null
+<?php
+return array(
+ array(
+ 'name' => 'id',
+ 'required' => true,
+ 'filters' => array(
+ array('name' => 'Int'),
+ ),
+ ),
+ array(
+ 'name' => 'name',
+ 'required' => true,
+ 'filters' => array(
+ array('name' => 'StripTags'),
+ array('name' => 'StringTrim'),
+ ),
+ 'validators' => array(
+ array(
+ 'name' => 'StringLength',
+ 'options' => array(
+ 'encoding' => 'UTF-8',
+ 'min' => 1,
+ 'max' => 32,
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'name' => 'description',
+ 'required' => true,
+ 'filters' => array(
+ array('name' => 'StripTags'),
+ array('name' => 'StringTrim'),
+ ),
+ )
+ );