Score:0

How to nest fieldsets?

br flag

My goal is rather simple, I need to group several fieldsets in a fieldset like in the image below :

enter image description here

I tried with the following code :

    public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
        
        foreach ($this -> order -> getItems() as $key => $order_item) {
            
            dpm($order_item -> getPurchasedEntity() -> getProduct() -> bundle());
            $quantity = round($order_item -> getQuantity());
        
            $pane_form['pilote_'.$key] = array(
                    '#title' => $order_item -> getPurchasedEntity() -> getProduct() -> getTitle(),
                    '#type' => 'fieldset',
                    '#description' => "Saisissez les coordonnées des pilotes à assurer",
            );
            
            for($i = 0; $i < $quantity; $i ++) {
                
                $pane_form['pilote_'.$key]['ss_pilote_'.$i]  = array(
                        '#title' => 'Pilote '.($i+1),
                        '#type' => 'fieldset',
                );
                
                $pane_form['pilote'.$key]['ss_pilote_'.$i]['pilote_nom_'.$i] = array(
                        '#type' => 'textfield',
                        '#title' => 'Nom',
                        '#default_value' => '',
                        '#required' => TRUE,
                        '#size' => 20,
                        '#attributes' => array(),
                );
                    
                $pane_form['pilote'.$key]['ss_pilote_'.$i]['pilote_prenom_'.$i] = array(
                        '#type' => 'textfield',
                        '#title' => 'Prenom',
                        '#required' => TRUE,
                        '#default_value' => '',
                        '#size' => 20,
                        '#attributes' => array(),
                );
                    
                $pane_form['pilote'.$key]['ss_pilote_'.$i]['pilote_email_'.$i] = array(
                        '#type' => 'textfield',
                        '#title' => 'Email',
                        '#default_value' => '',
                        '#required' => TRUE,
                        '#size' => 20,
                        '#attributes' => array(),
                );
                
            }
            
        };
        
        return $pane_form;
    }

but i still get this :

enter image description here

can anyone help me get the desired result ?

Thanks in advance for your answers :-)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.