Skip to content
Snippets Groups Projects
Select Git revision
  • 548fbec1fa700be59eb25039cac95bf67f26451f
  • master default protected
  • pcre
3 results

main.cf

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    OseForm.php 1.69 KiB
    <?php
    
    namespace <namespace>;
    
    <if useSubForm>
    use Application\Form\AbstractForm;
    <endif useSubForm>
    <if useHydrator>
    use Zend\Stdlib\Hydrator\HydratorInterface;
    <endif useHydrator>
    
    
    
    /**
     * Description of <classname>
     *
     * @author <author>
     */
    class <classname> extends AbstractForm
    {
    
        public function init()
        {
            <if useHydrator>
            $hydrator = new <classname>Hydrator;
            $this->setHydrator($hydrator);
            <endif useHydrator>
    
            $this->setAttribute('action',$this->getCurrentUrl());
    
            /* Ajoutez vos éléments de formulaire ici */
    
            $this->add([
                'name'       => 'submit',
                'type'       => 'Submit',
                'attributes' => [
                    'value' => 'Enregistrer',
                    'class' => 'btn btn-primary',
                ],
            ]);
        }
    
    
    
        /**
         * Should return an array specification compatible with
         * {@link Zend\InputFilter\Factory::createInputFilter()}.
         *
         * @return array
         */
        public function getInputFilterSpecification()
        {
            return [
                /* Filtres et validateurs */
            ];
        }
    }
    
    
    
    
    
    <if useHydrator>
    class <classname>Hydrator implements HydratorInterface
    {
    
        /**
         * @param  array    $data
         * @param           $object
         *
         * @return object
         */
        public function hydrate(array $data, $object)
        {
            /* on peuple l'objet à partir du tableau de données */
    
            return $object;
        }
    
    
    
        /**
         * @param  $object
         *
         * @return array
         */
        public function extract($object)
        {
            $data = [
                /* On peuple le tableau avec les données de l'objet */
            ];
    
            return $data;
        }
    }
    <endif useHydrator>