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 :

Formulaire CollectionType Field


Sujet :

Symfony PHP

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2011
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2011
    Messages : 26
    Par défaut Formulaire CollectionType Field
    Bonjour à tous,

    Actuellement en projet scolaire et je suis bloqué sur la réalisation d'une fonctionnalité.

    J'explique :

    Voici dans un premier temps les tables concernées, je vous ai mis le MCD en PJ.

    Pour résumer, je dois afficher un catalog qui contient une liste de produits à vendre.
    Un catalogue peut contenir un ou plusieurs produis.
    Les produits sont des packs, qui sont composés d'un quota, d'un prix et d'une durée.
    A savoir que un pack est lié a un seul et unique quota
    Mais un pack peut avoir différentes durées et un prix associé à cette durée.

    Ce que je souhaite c'est afficher les différents packs sous forme de tableau :

    Nom du pack / label Durée 1 / label Durée 2 / label Durée 3

    Pack 1 => Prix durée 1 (RadioButton) / Prix durée 2 (RadioButton) / Prix durée 3 (RadioButton)
    Pack 2 => Prix durée 1 (RadioButton) / Prix durée 2 (RadioButton) / Prix durée 3 (RadioButton)
    Pack 3 => Prix durée 1 (RadioButton) / Prix durée 2 (RadioButton) / Prix durée 3 (RadioButton)

    Et afficher pour chaque prix un radio button a coté de ce prix.

    L'utilisateur cochera une des radiobutton en fonction de ce qu'il souhaite.
    Exemple : si le client souhaite acheter le Pack 1 avec la durée 2 et le pack 3 avec la durée 1. Il devra cocher le radiobutton correspondant à ses souhaits.

    Voici mes différentes class :

    Entité Catalog :

    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
    <?php
     
    namespace AppBundle\Entity\Shop;
     
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
     
    use AppBundle\Traits\QuotaTrait;
    use Symfony\Component\Validator\Constraints\Date;
     
    /**
     * Catalog
     *
     * @ORM\Table(name="catalog")
     * @ORM\Entity(repositoryClass="AppBundle\Repository\Shop\CatalogRepository")
     */
    class Catalog
    {
        use QuotaTrait;
        /**
         * @var int
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @var string
         *
         * @ORM\Column(name="name", type="string", length=255)
         */
        private $name;
     
        /**
         * @ORM\OneToMany(targetEntity="AppBundle\Entity\Shop\CatalogPack", cascade={"persist", "remove"}, orphanRemoval=true, mappedBy="catalog")
         * @ORM\JoinColumn(nullable=true)
         */
        private $packs;
     
        public function __construct()
        {
            $this->packs = new ArrayCollection();
        }
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set name
         *
         * @param string $name
         * @return Catalog
         */
        public function setName($name)
        {
            $this->name = $name;
     
            return $this;
        }
     
        /**
         * Get name
         *
         * @return string 
         */
        public function getName()
        {
            return $this->name;
        }
     
        /**
         * @return mixed
         */
        public function getPacks()
        {
            return $this->packs;
        }
     
        /**
         * @param mixed $packs
         */
        public function setPacks($packs)
        {
            $this->packs = $packs;
        }
     
        public function addPack(CatalogPack $pack)
        {
            $this->packs[] = $pack;
     
            $pack->setCatalog($this);
            return $this;
        }
     
        public function removePack(CatalogPack $pack)
        {{{ form_start(form) }}
                        <table border="1" cellspacing="0" style="border: 1px solid black; width: 100%;">
                            <thead style="background-color: #414045;">
                            <tr class="trHeader"
                                style="height: 50px; background-color: #d1201d; opacity: 0.8; color: #e7e7e7;">
                                <th colspan="5">Sauvegardez au bon prix</th>
                            </tr>
                            <tr class="trHeader" style="height: 50px">
                                <th>Quota</th>
                                <th>Sans engagement</th>
                                <th>2 ans</th>
                                <th>3 ans</th>
                                <th>Prix / licence</th>
                            </tr>
                            </thead>
                            <tbody style="background-color: #414045;">
                            {{ form_errors(form) }}
                            {% set catalog_packs = form.packs %}
     
                            {% for catalog_pack in catalog_packs %}
                                {% set pack = catalog_pack.pack %}
                                <tr>
                                    <td>
                                        {{ form_widget(pack.name) }}
                                    </td>
                                    {% for element in pack.packElement %}
                                            <td>
                                                {{ form_widget(element) }}
                                            </td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
            $this->packs->removeElement($pack);
        }
    }
    Entité CatalogPack :

    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
    <?php
     
    namespace AppBundle\Entity\Shop;
     
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
    use Symfony\Component\Validator\Constraints as Assert;
     
    /**
     * CatalogProduct
     *
     * @ORM\Table(name="catalog_pack")
     * @ORM\Entity(repositoryClass="AppBundle\Repository\Shop\CatalogPackRepository")
     */
    class CatalogPack
    {
        /**
         * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Shop\Catalog", inversedBy="packs")
         * @ORM\JoinColumn(name="catalog_id", referencedColumnName="id", nullable=true)
         */
        private $catalog;
     
        /**
         * @ORM\Id
         * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Shop\Pack", inversedBy="catalog")
         * @ORM\JoinColumn(name="pack_id", referencedColumnName="id", nullable=true)
         */
        private $pack;
     
        /**
         * @return mixed
         */
        public function getCatalog()
        {
            return $this->catalog;
        }
     
        /**
         * @param mixed $catalog
         */
        public function setCatalog($catalog)
        {
            $this->catalog = $catalog;
        }
     
        /**
         * @return mixed
         */
        public function getPack()
        {
            return $this->pack;
        }
     
        /**
         * @param mixed $pack
         */
        public function setPack($pack)
        {
            $this->pack = $pack;
        }
     
        public function __toString()
        {
            // TODO: Implement __toString() method.
     
            return (string) $this->getPack();
        }
    }
    Entité Pack :
    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
    <?php
     
    namespace AppBundle\Entity\Shop;
     
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * Pack
     *
     * @ORM\Table(name="pack")
     * @ORM\Entity(repositoryClass="AppBundle\Repository\PackRepository")
     */
    class Pack
    {
        /**
         * @var int
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @var string
         *
         * @ORM\Column(name="name", type="string")
         */
        protected $name;
     
        /**
         * @var boolean
         *
         * @ORM\Column(name="activate", type="boolean")
         */
        protected $activate;
     
        /**
         * @ORM\oneToMany(targetEntity="AppBundle\Entity\Shop\CatalogPack", mappedBy="pack")
         * @ORM\JoinColumn(nullable=false)
         */
        private $catalog;
     
        /**
         * @ORM\OneToMany(targetEntity="AppBundle\Entity\Shop\PackElement",cascade={"persist", "remove"}, orphanRemoval=true ,mappedBy="pack")
         * @ORM\JoinColumn(nullable=false)
         */
        private $packElement;
     
        /**
         * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Shop\PackQuota",cascade={"persist"})
         * @ORM\JoinColumn(nullable=false)
         */
        private $quota;
     
        public function __construct()
        {
            $this->packElement = new ArrayCollection();
        }
     
        public function __toString()
        {
            return '' . $this->name ;
        }
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * @return string
         */
        public function getName()
        {
            return $this->name;
        }
     
        /**
         * @param string $name
         */
        public function setName($name)
        {
            $this->name = $name;
        }
     
        /**
         * @return boolean
         */
        public function isActivate()
        {
            return $this->activate;
        }
     
        /**
         * @param boolean $activate
         */
        public function setActivate($activate)
        {
            $this->activate = $activate;
        }
     
        /**
         * @return mixed
         */
        public function getCatalog()
        {
            return $this->catalog;
        }
     
        /**
         * @param mixed $catalog
         */
        public function setCatalog($catalog)
        {
            $this->catalog = $catalog;
        }
     
        /**
         * @return mixed
         */
        public function getQuota()
        {
            return $this->quota;
        }
     
        /**
         * @param mixed $quota
         */
        public function setQuota($quota)
        {
            $this->quota = $quota;
        }
     
        /**
         * @return mixed
         */
        public function getPackElement()
        {
            return $this->packElement;
        }
     
        /**
         * @param PackElement $element
         * @return $this
         */
        public function addPackElement(PackElement $element)
        {
            $this->packElement[] = $element;
     
            $element->setPack($this);
            return $this;
        }
     
        /**
         * @param PackElement $element
         */
        public function removePackElement(PackElement $element)
        {
            $this->packElement->removeElement($element);
        }
    Entité PackElement :

    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
    <?php
     
    namespace AppBundle\Entity\Shop;
     
    use Doctrine\ORM\Mapping as ORM;
    use Doctrine\ORM\Mapping\Id;
     
    /**
     * PackElement
     *
     * @ORM\Table(name="pack_element")
     * @ORM\Entity(repositoryClass="AppBundle\Repository\Shop\PackElementRepository")
     */
    class PackElement
    {
        /**
         * @var int
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Shop\PackDuration", inversedBy="packElement")
         * @ORM\JoinColumn(name="pack_duration_id", referencedColumnName="id", nullable=true, unique=false)
         */
        private $packDuration;
     
        /**
         * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Shop\Pack", inversedBy="packElement")
         * @ORM\JoinColumn(name="pack_id", referencedColumnName="id", nullable=true, unique=false)
         */
        private $pack;
     
        /**
         * @var string
         *
         * @ORM\Column(name="price", type="decimal", precision=10, scale=2)
         */
        private $price;
     
        public function __toString()
        {
            return (string) $this->getPrice();
        }
     
        /**
         * @return mixed
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * @param mixed $id
         */
        public function setId($id)
        {
            $this->id = $id;
        }
        /**
         * @return mixed
         */
        public function getPackDuration()
        {
            return $this->packDuration;
        }
     
        /**
         * @param mixed $packDuration
         */
        public function setPackDuration($packDuration)
        {
            $this->packDuration = $packDuration;
        }
     
        /**
         * @return mixed
         */
        public function getPack()
        {
            return $this->pack;
        }
     
        /**
         * @param mixed $pack
         */
        public function setPack($pack)
        {
            $this->pack = $pack;
        }
     
        /**
         * @return string
         */
        public function getPrice()
        {
            return $this->price;
        }
     
        /**
         * @param string $price
         */
        public function setPrice($price)
        {
            $this->price = $price;
        }
    }
    Mon FormType => Catalogtype.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
    <?php
     
    namespace AppBundle\Form\Type;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\Extension\Core\Type\CollectionType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\OptionsResolver\OptionsResolver;
     
    use Symfony\Component\Form\Extension\Core\Type\SubmitType;
     
    class CatalogType extends AbstractType
    {
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $builder
                ->add('packs', CollectionType::class, array(
                    'type' => CatalogPackType::class
                ))
                ->add('buy', SubmitType::class, array(
                    'attr' => array('class' => 'btn-buy'),
                ));
                ;
        }
     
        public function configureOptions(OptionsResolver $resolver)
        {
            $resolver->setDefaults(array(
                'data_class' => 'AppBundle\Entity\Shop\Catalog',
            ));
        }
     
        public function getName()
        {
            return 'app_bundle_catalog_type';
        }
    }
    Mon FormType => CatalogPackType.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
    <?php
     
    namespace AppBundle\Form\Type;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\OptionsResolver\OptionsResolver;
     
    class CatalogPackType extends AbstractType
    {
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $builder->add('pack', PackType::class);
        }
     
        public function configureOptions(OptionsResolver $resolver)
        {
            $resolver->setDefaults(array(
                'data_class' => 'AppBundle\Entity\Shop\CatalogPack',
            ));
        }
     
        public function getName()
        {
            return 'app_bundle_catalog_pack';
        }
    }
    Mon FormType => PackType.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
    <?php
     
    namespace AppBundle\Form\Type;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\Extension\Core\Type\RadioType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\OptionsResolver\OptionsResolver;
    use Symfony\Component\Form\Extension\Core\Type\TextType;
    use Symfony\Component\Form\Extension\Core\Type\CollectionType;
     
    class PackType extends AbstractType
    {
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $builder->add('name', TextType::class)
                    ->add('packElement', CollectionType::class);
        }
     
        public function configureOptions(OptionsResolver $resolver)
        {
            $resolver->setDefaults([
                'data_class' => 'AppBundle\Entity\Shop\Pack'
            ]);
        }
     
        public function getName()
        {
            return 'app_bundle_pack_type';
        }
    }
    Controller du catalog :

    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
    class CatalogController extends Controller
    {
        /**
         * @param Request $request
         * @return Response
         */
        public function indexAction(Request $request)
        {
            $request = $this->container->get('request_stack')->getCurrentRequest();
            $session = $request->getSession();
     
            $em = $this->getDoctrine()->getManager();
            $catalog = $em->getRepository('AppBundle:Shop\Catalog')
                ->findOneByName("Client");
     
     
            $form = $this->get('form.factory')->create(new CatalogType(), $catalog);
            $form->handleRequest($request);
            if ($form->isValid()) {
     
            }
     
            return $this->render('shop/catalog.html.twig', array(
                'form' => $form->createView(),
                'catalog' => $catalog
            ));
        }
    Vue catalog.html.twig
    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
     
    {{ form_start(form) }}
                        <table border="1" cellspacing="0" style="border: 1px solid black; width: 100%;">
                            <thead style="background-color: #414045;">
                            <tr style="height: 50px">
                                <th>Quota</th>
                                <th>Sans engagement</th>
                                <th>2 ans</th>
                                <th>3 ans</th>
                            </tr>
                            </thead>
                            <tbody style="background-color: #414045;">
                            {{ form_errors(form) }}
                            {% set catalog_packs = form.packs %}
     
                            {% for catalog_pack in catalog_packs %}
                                {% set pack = catalog_pack.pack %}
                                <tr>
                                    <td>
                                        {{ form_widget(pack.name) }}
                                    </td>
                                    {% for element in pack.packElement %}
                                            <td>
                                                {{ form_widget(element) }}
                                            </td>
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
    Avec mon formulaire PackType, j'arrive à afficher mon tableau comme je le souhaite mais chaque élement est un input de type text.

    Voici la vue générée :

    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
     
    <form name="app_bundle_catalog_type" method="post">
        <table border="1" cellspacing="0" style="border: 1px solid black; width: 100%;">
            <thead style="background-color: #414045;">
                <tr style="height: 50px">
                    <th>Quota</th>
                    <th>Sans engagement</th>
                    <th>2 ans</th>
                    <th>3 ans</th>
                </tr>
            </thead>
            <tbody style="background-color: #414045;">
                <tr>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_0_pack_name" name="app_bundle_catalog_type[packs][0][pack][name]" required="required" value="Pack 5Go" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_0_pack_packElement_0" name="app_bundle_catalog_type[packs][0][pack][packElement][0]" required="required" value="12.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_0_pack_packElement_1" name="app_bundle_catalog_type[packs][0][pack][packElement][1]" required="required" value="8.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_0_pack_packElement_2" name="app_bundle_catalog_type[packs][0][pack][packElement][2]" required="required" value="6.00" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_1_pack_name" name="app_bundle_catalog_type[packs][1][pack][name]" required="required" value="Pack 10Go" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_1_pack_packElement_0" name="app_bundle_catalog_type[packs][1][pack][packElement][0]" required="required" value="24.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_1_pack_packElement_1" name="app_bundle_catalog_type[packs][1][pack][packElement][1]" required="required" value="16.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_1_pack_packElement_2" name="app_bundle_catalog_type[packs][1][pack][packElement][2]" required="required" value="12.00" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_2_pack_name" name="app_bundle_catalog_type[packs][2][pack][name]" required="required" value="Pack 20Go" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_2_pack_packElement_0" name="app_bundle_catalog_type[packs][2][pack][packElement][0]" required="required" value="48.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_2_pack_packElement_1" name="app_bundle_catalog_type[packs][2][pack][packElement][1]" required="required" value="32.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_2_pack_packElement_2" name="app_bundle_catalog_type[packs][2][pack][packElement][2]" required="required" value="24.00" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_3_pack_name" name="app_bundle_catalog_type[packs][3][pack][name]" required="required" value="Pack 50Go" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_3_pack_packElement_0" name="app_bundle_catalog_type[packs][3][pack][packElement][0]" required="required" value="120.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_3_pack_packElement_1" name="app_bundle_catalog_type[packs][3][pack][packElement][1]" required="required" value="80.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_3_pack_packElement_2" name="app_bundle_catalog_type[packs][3][pack][packElement][2]" required="required" value="60.00" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_4_pack_name" name="app_bundle_catalog_type[packs][4][pack][name]" required="required" value="Pack 100Go" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_4_pack_packElement_0" name="app_bundle_catalog_type[packs][4][pack][packElement][0]" required="required" value="240.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_4_pack_packElement_1" name="app_bundle_catalog_type[packs][4][pack][packElement][1]" required="required" value="160.00" />
                    </td>
                    <td>
                        <input type="text" id="app_bundle_catalog_type_packs_4_pack_packElement_2" name="app_bundle_catalog_type[packs][4][pack][packElement][2]" required="required" value="120.00" />
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
    Voilà j'aimerai savoir si c'est possible de transformer ces input de type text en checkbox.

    J'ai une autre solution, mais je ne pense pas que ce soit optimisée, comme par exemple faire un render de la vue dans mon controller en passant mes différents packs puis en ajax envoyer les données cochées.
    Mais j'aimerai renvoyer à mon controller des objets plutôt que des données que je devrais vérifier coté server.

    Je ne sais pas si ce que j'ai commencé à faire et la bonne chose à faire. est il possible d'arriver à ce que je souhaite ou faut il faire autrement ?

    J'espère avoir été clair.
    Merci d'avance pour vos retours.
    N'hésitez pas si vous souhaitez avoir des informations supplémentaire mais je pense vous avoir donnée tous les éléments important.

    Cordialement
    Images attachées Images attachées  

Discussions similaires

  1. Required field ou champ obligatoire dans les formulaires sous Jahia
    Par donkeykick dans le forum Développement Web en Java
    Réponses: 0
    Dernier message: 07/07/2015, 16h11
  2. [2.x] [Form] Réaliser un simple formulaire Entity Field Type
    Par Lex92 dans le forum Symfony
    Réponses: 10
    Dernier message: 25/09/2012, 12h21
  3. [2.x] Formulaire et Entity Field
    Par Sports dans le forum Symfony
    Réponses: 0
    Dernier message: 06/06/2012, 18h38
  4. Formulaire: Drop down virtuelle (cache browser) sur input field
    Par Stessy dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 06/12/2010, 09h02
  5. [AC-2007] Source d'un Field en vba dans un formulaire
    Par franckimmo dans le forum IHM
    Réponses: 6
    Dernier message: 24/02/2010, 09h32

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