A question about from builder

edited August 2017 in Modules
Hi I'm building from by from builder recently, I use fieldset to group fields under the fieldset field. Any way I can stop the fieldset to continue group all fields below it ? (e.g. only group 3 or 4 fields and then go back to normal list for other remain fields)

Comments

  • edited 3:20PM
    Not at this time.
  • Sorry for digging out this old question, but if someone searches for this, you can add tabs into the form flow as described above. (I couldn't find a solution here)

    | Tab | Tab 2 | Tab 3 |
    
      [ form field 1]
      [ form field 2]
    
    [form field outside of tabs]
    [form field outside of tabs2]
    
    [submit]
    
    
    <?php
    
        function form_fields($values = array(), $related = array())
        {
            $fields = parent::form_fields($values, $related);
    
            $CI =& get_instance();
    
            $fields['description_fieldset_de'] = array('type' => 'fieldset', 'label' => 'Location (DE)', 'order' => 200, 'class' => 'tab');
            $fields['description_fieldset_en'] = array('type' => 'fieldset', 'label' => 'Location (EN)', 'order' => 200, 'class' => 'tab');
            $fields['description_fieldset_cs'] = array('type' => 'fieldset', 'label' => 'Location (CS)', 'order' => 200, 'class' => 'tab');
    
            // move selected fields into an array
            $f = [
                'description_fieldset_de' => $fields['description_fieldset_de'],
                'name'                    => $fields['name'],
                'description'             => $fields['description'],
                'description_fieldset_en' => $fields['description_fieldset_en'],
                'name_en'                 => $fields['name_en'],
                'description_en'          => $fields['description_en'],
                'description_fieldset_cs' => $fields['description_fieldset_cs'],
                'name_cs'                 => $fields['name_cs'],
                'description_cs'          => $fields['description_cs'],
            ];
    
            foreach(array_keys($f) as $i => $key){
                unset($fields[$key]); // remove fields from main $fields array
                $f[$key]['order'] = $i + 1; // set order of fields
            }
    
            // define nested fields
            $fields['nested_header'] = [
                'type' => 'nested',
                'fields' => $f,
                'display_label' => FALSE,
                'init' => [],
                'value' => $values // pass values to the form_builder instance, else the fields stay empty after saving
            ];
    
            $order = [
                'id',
                'nested_header',
                'category_id',
                'image',
            ];
    
            foreach($order as $key => $val)
            {
                $fields[$val]['order'] = $key + 1;
            }
    
            return $fields;
        }
    
    
Sign In or Register to comment.