Hello All,

I am developing the module which included the multi-field form. I have grouped them into different field. Attached PHP is one of the example of my code. They work and run perfectly.

$form['fieldset_of_personal_information'][$fieldset_number] = array(
	'#type' => 'fieldset',
	'#title' => 'Field Set'.$fieldset_number,
	'#collapsible' => TRUE,
	'#collapsed' => TRUE,
);
$form['fieldset_of_personal_information'][$fieldset_number][$fieldA] = array(
	'#type' => 'textfield',
	'#title' => $fieldA_name,
	'#default_value' => $fieldA_defaultvalue,
);

I found there is no way to work with same effect of accordion without creating any extra tpl file in original drupal, except Field Group.

I am trying to have a program like this:

$form['fieldset_of_personal_information'][$accordion_number]['accordion'] = array(
	'#type' => 'accordion',
);
$form['fieldset_of_personal_information'][$accordion_number]['accordion_item'] = array(
	'#type' => 'accordion_item',
);
$form['fieldset_of_personal_information'][$accordion_number][$fieldA] = array(
	'#type' => 'textfield',
	'#title' => $fieldA_name,
	'#default_value' => $fieldA_defaultvalue,
);

I spent over a days to find the solution but no luck to be success. It doesn't show up accordion, only the textfield can be rendered on pages.

Are there something wrong?

Please let me know if there is any missing or unclear. I am still an newbie in Drupal.

Thanks for your help in advance and looking forward to hear from you.

Regards,
Samuel

Comments

samuelli’s picture

Issue summary: View changes

Typo

samuelli’s picture

Issue summary: View changes

Adding the code tag

nils.destoop’s picture

Status: Active » Closed (fixed)

There is no element type accordion_item in D7, in d8 your example will work.