IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

lier plusieurs entités en 1 formulaire [2.x]


Sujet :

Symfony PHP

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    125
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 125
    Points : 108
    Points
    108
    Par défaut lier plusieurs entités en 1 formulaire
    Bonjour,
    Je cherche à construire un formulaire qui regroupe plusieurs entités sous differentes forme et je galère un peu( beaucoup même !!).

    J'ai une entité Forfait qui contient plusieurs champ. Celle-ci je souhaite pouvoir en créer une nouvelle dans le formulaire en question.
    J'ai une entité Prestation qui contient également plusieurs champs, mais celle-ci sont déjà créées et je souhaiterai faire une liste de toutes mes prestations existante et pouvoir choisir lesquelles je souhaite relier au forfait que je suis entrain de créer.
    Ma 3e entité PrestationForfait, c'est en faite elle que j'ai choisit pour faire le lien entre mes deux autres entités elle a un champ en plus que les id des deux autres entités, cest le champ Quantité. je souhaiterai pouvoir lorsque je relis une prestation à un forfait mettre la quantité pour chaque prestation.

    Je pars sur l'idée de faire un formulaire imbriqué à partir de PrestationForfait imbriquant forfait en collection. (bien pas bien ?)
    Comment je peux créer une liste de toute mes prestations dans ce formulaire et rajouter seulement celles qui ont une quantité > 0 ?

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    125
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 125
    Points : 108
    Points
    108
    Par défaut
    mes entités:
    Forfait:
    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    <?php
     
    namespace SB\PrestaBundle\Entity;
     
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Forfait
     *
     * @ORM\Table()
     * @ORM\Entity(repositoryClass="SB\PrestaBundle\Entity\ForfaitRepository")
     */
    class Forfait
    {
        /**
         * @ORM\OneToMany(targetEntity="SB\PrestaBundle\Entity\QuttPrestaForfait", mappedBy="forfait")
         */
        private $quttprestaforfait;
     
        /**
         * @ORM\ManyToOne(targetEntity="SB\PrestaBundle\Entity\Prestacateg")
         * @ORM\JoinColumn(nullable=false)
         */
        private $prestacateg;
     
        /**
         * @ORM\ManyToMany(targetEntity="SB\PrestaBundle\Entity\Presta")
         */
        private $prestas;
     
        /**
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @var string
         *
         * @ORM\Column(name="title", type="string", length=255)
         */
        private $title;
     
        /**
         * @var string
         *
         * @ORM\Column(name="comment", type="text")
         */
        private $comment;
     
        /**
         * @var integer
         *
         * @ORM\Column(name="prix", type="integer")
         */
        private $prix;
     
        /**
         * @var boolean
         *
         * @ORM\Column(name="afficher", type="boolean")
         */
        private $afficher;
     
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set title
         *
         * @param string $title
         * @return Forfait
         */
        public function setTitle($title)
        {
            $this->title = $title;
     
            return $this;
        }
     
        /**
         * Get title
         *
         * @return string 
         */
        public function getTitle()
        {
            return $this->title;
        }
     
        /**
         * Set comment
         *
         * @param string $comment
         * @return Forfait
         */
        public function setComment($comment)
        {
            $this->comment = $comment;
     
            return $this;
        }
     
        /**
         * Get comment
         *
         * @return string 
         */
        public function getComment()
        {
            return $this->comment;
        }
     
        /**
         * Set prix
         *
         * @param integer $prix
         * @return Forfait
         */
        public function setPrix($prix)
        {
            $this->prix = $prix;
     
            return $this;
        }
     
        /**
         * Get prix
         *
         * @return integer 
         */
        public function getPrix()
        {
            return $this->prix;
        }
     
        /**
         * Set afficher
         *
         * @param boolean $afficher
         * @return Forfait
         */
        public function setAfficher($afficher)
        {
            $this->afficher = $afficher;
     
            return $this;
        }
     
        /**
         * Get afficher
         *
         * @return boolean 
         */
        public function getAfficher()
        {
            return $this->afficher;
        }
        /**
         * Constructor
         */
        public function __construct()
        {
            $this->prestas = new \Doctrine\Common\Collections\ArrayCollection();
            $this->quttprestaforfait = new \Doctrine\Common\Collections\ArrayCollection();
     
        }
     
        /**
         * Add prestas
         *
         * @param \SB\PrestaBundle\Entity\Presta $prestas
         * @return Forfait
         */
        public function addPresta(\SB\PrestaBundle\Entity\Presta $prestas)
        {
            $this->prestas[] = $prestas;
     
            return $this;
        }
     
        /**
         * Remove prestas
         *
         * @param \SB\PrestaBundle\Entity\Presta $prestas
         */
        public function removePresta(\SB\PrestaBundle\Entity\Presta $prestas)
        {
            $this->prestas->removeElement($prestas);
        }
     
        /**
         * Get prestas
         *
         * @return \Doctrine\Common\Collections\Collection 
         */
        public function getPrestas()
        {
            return $this->prestas;
        }
     
        /**
         * Set prestacateg
         *
         * @param \SB\PrestaBundle\Entity\Prestacateg $prestacateg
         * @return Forfait
         */
        public function setPrestacateg(\SB\PrestaBundle\Entity\Prestacateg $prestacateg)
        {
            $this->prestacateg = $prestacateg;
     
            return $this;
        }
     
        /**
         * Get prestacateg
         *
         * @return \SB\PrestaBundle\Entity\Prestacateg 
         */
        public function getPrestacateg()
        {
            return $this->prestacateg;
        }
     
        /**
         * Add quttprestaforfait
         *
         * @param \SB\PrestaBundle\Entity\QuttPrestaForfait $quttprestaforfait
         * @return Forfait
         */
        public function addQuttprestaforfait(\SB\PrestaBundle\Entity\QuttPrestaForfait $quttprestaforfait)
        {
            $this->quttprestaforfait[] = $quttprestaforfait;
     
            return $this;
        }
     
        /**
         * Remove quttprestaforfait
         *
         * @param \SB\PrestaBundle\Entity\QuttPrestaForfait $quttprestaforfait
         */
        public function removeQuttprestaforfait(\SB\PrestaBundle\Entity\QuttPrestaForfait $quttprestaforfait)
        {
            $this->quttprestaforfait->removeElement($quttprestaforfait);
        }
     
        /**
         * Get quttprestaforfait
         *
         * @return \Doctrine\Common\Collections\Collection 
         */
        public function getQuttprestaforfait()
        {
            return $this->quttprestaforfait;
        }
    }
    prestation:
    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    <?php
     
    namespace SB\PrestaBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Presta
     *
     * @ORM\Table()
     * @ORM\Entity(repositoryClass="SB\PrestaBundle\Entity\PrestaRepository")
     */
    class Presta
    {
        /**
         * @ORM\OneToMany(targetEntity="SB\PrestaBundle\Entity\QuttPrestaForfait", mappedBy="presta")
         */
        private $quttprestaforfait;
     
        /**
         * @ORM\ManyToOne(targetEntity="SB\PrestaBundle\Entity\Prestacateg")
         * @ORM\JoinColumn(nullable=false)
         */
        private $prestacateg;
     
        /**
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @var string
         *
         * @ORM\Column(name="title", type="string", length=255)
         */
        private $title;
     
        /**
         * @var string
         *
         * @ORM\Column(name="comment", type="string", length=255)
         */
        private $comment;
     
        /**
         * @var integer
         *
         * @ORM\Column(name="prix", type="integer")
         */
        private $prix;
     
        /**
         * @var boolean
         *
         * @ORM\Column(name="afficher", type="boolean")
         */
        private $afficher;
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set title
         *
         * @param string $title
         * @return Presta
         */
        public function setTitle($title)
        {
            $this->title = $title;
     
            return $this;
        }
     
        /**
         * Get title
         *
         * @return string 
         */
        public function getTitle()
        {
            return $this->title;
        }
     
        /**
         * Set comment
         *
         * @param string $comment
         * @return Presta
         */
        public function setComment($comment)
        {
            $this->comment = $comment;
     
            return $this;
        }
     
        /**
         * Get comment
         *
         * @return string 
         */
        public function getComment()
        {
            return $this->comment;
        }
     
        /**
         * Set prix
         *
         * @param integer $prix
         * @return Presta
         */
        public function setPrix($prix)
        {
            $this->prix = $prix;
     
            return $this;
        }
     
        /**
         * Get prix
         *
         * @return integer 
         */
        public function getPrix()
        {
            return $this->prix;
        }
     
        /**
         * Set afficher
         *
         * @param boolean $afficher
         * @return Presta
         */
        public function setAfficher($afficher)
        {
            $this->afficher = $afficher;
     
            return $this;
        }
     
        /**
         * Get afficher
         *
         * @return boolean 
         */
        public function getAfficher()
        {
            return $this->afficher;
        }
     
        /**
         * Set prestacateg
         *
         * @param \SB\PrestaBundle\Entity\Prestacateg $prestacateg
         * @return Presta
         */
        public function setPrestacateg(\SB\PrestaBundle\Entity\Prestacateg $prestacateg)
        {
            $this->prestacateg = $prestacateg;
     
            return $this;
        }
     
        /**
         * Get prestacateg
         *
         * @return \SB\PrestaBundle\Entity\Prestacateg 
         */
        public function getPrestacateg()
        {
            return $this->prestacateg;
        }
        /**
         * Constructor
         */
        public function __construct()
        {
            $this->quttprestaforfait = new \Doctrine\Common\Collections\ArrayCollection();
        }
     
        /**
         * Add quttprestaforfait
         *
         * @param \SB\PrestaBundle\Entity\QuttPrestaForfait $quttprestaforfait
         * @return Presta
         */
        public function addQuttprestaforfait(\SB\PrestaBundle\Entity\QuttPrestaForfait $quttprestaforfait)
        {
            $this->quttprestaforfait[] = $quttprestaforfait;
     
            return $this;
        }
     
        /**
         * Remove quttprestaforfait
         *
         * @param \SB\PrestaBundle\Entity\QuttPrestaForfait $quttprestaforfait
         */
        public function removeQuttprestaforfait(\SB\PrestaBundle\Entity\QuttPrestaForfait $quttprestaforfait)
        {
            $this->quttprestaforfait->removeElement($quttprestaforfait);
        }
     
        /**
         * Get quttprestaforfait
         *
         * @return \Doctrine\Common\Collections\Collection 
         */
        public function getQuttprestaforfait()
        {
            return $this->quttprestaforfait;
        }
    }
    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    <?php
     
    namespace SB\PrestaBundle\Entity;
     
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * QuttPrestaForfait
     *
     * @ORM\Table()
     * @ORM\Entity(repositoryClass="SB\PrestaBundle\Entity\QuttPrestaForfaitRepository")
     */
    class QuttPrestaForfait
    {
        /**
         * @ORM\ManyToOne(targetEntity="SB\PrestaBundle\Entity\Forfait", inversedBy="quttprestaforfait")
         * @ORM\JoinColumn(nullable=false)
         */
        private $forfait;
     
        /**
         * @ORM\ManyToOne(targetEntity="SB\PrestaBundle\Entity\Presta", inversedBy="quttprestaforfait")
         * @ORM\JoinColumn(nullable=false)
         */
        private $presta;
     
     
        /**
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @var integer
         *
         * @ORM\Column(name="qutt", type="integer")
         */
        private $qutt;
     
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set qutt
         *
         * @param integer $qutt
         * @return QuttPrestaForfait
         */
        public function setQutt($qutt)
        {
            $this->qutt = $qutt;
     
            return $this;
        }
     
        /**
         * Get qutt
         *
         * @return integer 
         */
        public function getQutt()
        {
            return $this->qutt;
        }
     
        /**
         * Set presta
         *
         * @param \SB\PrestaBundle\Entity\Presta $presta
         * @return QuttPrestaForfait
         */
        public function setPresta(\SB\PrestaBundle\Entity\Presta $presta = null)
        {
            $this->presta = $presta;
     
            return $this;
        }
     
        /**
         * Get presta
         *
         * @return \SB\PrestaBundle\Entity\Presta 
         */
        public function getPresta()
        {
            return $this->presta;
        }
        /**
         * Constructor
         */
        public function __construct()
        {
            $this->forfait = new \Doctrine\Common\Collections\ArrayCollection();
            $this->presta = new \Doctrine\Common\Collections\ArrayCollection();
        }
     
        /**
         * Set forfait
         *
         * @param \SB\PrestaBundle\Entity\Forfait $forfait
         * @return QuttPrestaForfait
         */
        public function setForfait(\SB\PrestaBundle\Entity\Forfait $forfait = null)
        {
            $this->forfait = $forfait;
     
            return $this;
        }
     
        /**
         * Get forfait
         *
         * @return \SB\PrestaBundle\Entity\Forfait 
         */
        public function getForfait()
        {
            return $this->forfait;
        }
    }
    mon formtype:
    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
    40
    41
    42
    <?php
     
    namespace SB\PrestaBundle\Form;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\OptionsResolver\OptionsResolverInterface;
     
    class ForfaitType extends AbstractType
    {
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $builder
                ->add('title',   'text')
                ->add('comment', 'textarea')
                ->add('prix',    'integer')
                ->add('afficher','checkbox', array('required' => false))
                ->add('prestacateg', 'entity', array(
      'class'    => 'SBPrestaBundle:Prestacateg',
      'property' => 'title', 'expanded' => false,
      'multiple' => false, 'label' => false))
                ->add('quttprestaforfait', 'collection', array(
                'type' => new QuttPrestaForfaitType(),
                'label'        => 'Titre',
                'allow_add'    => true,
                'allow_delete' => true,
                'by_reference' => false,))
            ;
        }
     
        public function setDefaultOptions(OptionsResolverInterface $resolver)
        {
            $resolver->setDefaults(array(
                'data_class' => 'SB\PrestaBundle\Entity\Forfait'
            ));
        }
     
        public function getName()
        {
            return 'forfaittype';
        }
    }
    ma vue:
    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    {% extends '::base.html.twig' %}
    {% block body %}
    <div class="row-fluid">
     
          <!-- Main hero unit for a primary marketing message or call to action -->
          <div class="hero-unit">
            <p><h2>Nouveau forfait</h2>
    <div class="well">
      <form method="post" {{ form_enctype(form) }}>
      <ul class="form_prestas" data-prototype="{{ form_widget(form.quttprestaforfait.vars.prototype)|e }}">
            {% for quttprestaforfaitt in form.quttprestaforfait %}
                    <li>{{ form_row(quttprestaforfaitt) }}</li>
            {% endfor %}
    </ul>
    {{ form_rest(form) }}
    {#A placer ailleurs et à nettoyer#}
    <script>
    //Récupère le div qui contient la collection de tags
    var collectionHolder = $('ul.form_prestas');
     
    // ajoute un lien « add a tag »
    var $addTagLink = $('<a href="#" class="add_tag_link">Ajouter une console</a>');
    var $newLinkLi = $('<li></li>').append($addTagLink);
     
    $(document).ready(function() {
        collectionHolder.find('li').each(function() {
            addTagFormDeleteLink($(this));
        });
        collectionHolder.append($newLinkLi);
        $addTagLink.on('click', function(e) {
            // empêche le lien de créer un « # » dans l'URL
            e.preventDefault();
     
            // ajoute un nouveau formulaire tag (voir le prochain bloc de code)
            addTagForm(collectionHolder, $newLinkLi);
        });
    });
    function addTagForm(collectionHolder, $newLinkLi) {
        // Récupère l'élément ayant l'attribut data-prototype comme expliqué plus tôt
        var prototype = collectionHolder.attr('data-prototype');
     
        // Remplace '__name__' dans le HTML du prototype par un nombre basé sur
        // la longueur de la collection courante
        var newForm = prototype.replace(/__name__/g, collectionHolder.children().length);
     
        // Affiche le formulaire dans la page dans un li, avant le lien "ajouter un tag"
        var $newFormLi = $('<li></li>').append(newForm);
        addTagFormDeleteLink($newFormLi);
        $newLinkLi.before($newFormLi);
    }
    function addTagFormDeleteLink($tagFormLi) {
        var $removeFormA = $('<a href="#">Supprimer cette console</a>');
        $tagFormLi.append($removeFormA);
     
        $removeFormA.on('click', function(e) {
            // empêche le lien de créer un « # » dans l'URL
            e.preventDefault();
     
            // supprime l'élément li pour le formulaire de tag
            $tagFormLi.remove();
        });
    }
    </script>
        <input type="submit" class="btn btn-primary" />
      </form>
     
     
          </div></p></div><!--/.class hero unit -->
     
     
     
    </div> <!-- /row-fluid -->
    {% endblock %}
    mon controlleur:
    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
     
        public function newAction()
        {
            $forfait = new Forfait();
            $form = $this->createForm('forfaittype', $forfait);
     
            $request = $this->get('request');
            if ($request->getMethod() == 'POST') {
              $form->bind($request);
              if ($form->isValid()) {
                $em = $this->getDoctrine()->getManager();
                $em->persist($forfait);
                $em->flush();
                $this->get('session')->getFlashBag()->add('info', 'forfait');
                return $this->redirect($this->generateUrl('presta_admin_all_forfait'));
                }
              }
            return $this->render('SBPrestaBundle:ForfaitAdmin:newforfait.html.twig', array('form' => $form->createView()));
        }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [2.x] Lier une entité avec plusieurs entités
    Par LEF97 dans le forum Symfony
    Réponses: 2
    Dernier message: 21/11/2013, 07h55
  2. [2.x] Lier plusieurs fois des entités entre elles
    Par SAmpistaroy dans le forum Symfony
    Réponses: 8
    Dernier message: 21/07/2013, 01h26
  3. [2.x] adaptation tuto formulaire utilisant plusieurs entités
    Par vincent62120 dans le forum Symfony
    Réponses: 0
    Dernier message: 21/02/2013, 10h46
  4. Lier plusieurs formulaires
    Par dav2k dans le forum Général JavaScript
    Réponses: 27
    Dernier message: 05/08/2010, 09h35
  5. editer plusieurs entitées dans un seul formulaire.
    Par lepirlouit dans le forum Struts 1
    Réponses: 1
    Dernier message: 01/04/2010, 11h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo