I am working on the creation of an admin form from module, and all goes well, until I get this "Disabled" signal on a fieldset.
snippet of code:
$elname='about_text_d'; // consistent with the #name property of the form element next below
$elweight='-2'; // the weight of the element: lower numbers float to the top, should be 1 lower than the form element
$form['text']['about'][$elname] = array(
'#type' => 'select',
'#title' => t ('Block D'),
'#options'=> torch_get_pages(),
'#required' => FALSE,
'#description' => t('Set this to the page you want embedded. If it's not there yet, <a href="/node/add/page?destination=/admin/config/torch">create</a> it. NONE means it remains empty.'),
'#default_value' => torch_check_pages(config_get('torch.settings', $elname)),
'#weight' => $elweight+1,
);
$form['text']['about'][$elname.'_title'] = array(
'#type' => 'checkbox',
'#title' => t('Show title'),
'#default_value' => config_get('torch.settings', $elname.'_title'),
'#required' => FALSE,
'#weight' => $elweight+2,
);
$elname='about_text_e'; // consistent with the #name property of the form element next below
$elweight='0'; // the weight of the element: lower numbers float to the top, should be 1 lower than the form element
$form['text']['about'][$elname] = array(
'#type' => 'select',
'#title' => t ('Block E'),
'#options'=> torch_get_pages(),
'#required' => FALSE,
'#description' => t('Set this to the page you want embedded. If it's not there yet, <a href="/node/add/page?destination=/admin/config/torch">create</a> it. NONE means it remains empty.'),
'#default_value' => torch_check_pages(config_get('torch.settings', $elname)),
'#weight' => $elweight+1,
);
$form['text']['about'][$elname.'_title'] = array(
'#type' => 'checkbox',
'#title' => t('Show title'),
'#default_value' => config_get('torch.settings', $elname.'_title'),
'#required' => FALSE,
'#weight' => $elweight+2,
);
$elname='about_text_f'; // consistent with the #name property of the form element next below
$elweight='2'; // the weight of the element: lower numbers float to the top, should be 1 lower than the form element
$form['text']['about'][$elname] = array(
'#type' => 'select',
'#title' => t ('Block F'),
'#options'=> torch_get_pages(),
'#required' => FALSE,
'#description' => t('Set this to the page you want embedded. If it's not there yet, <a href="/node/add/page?destination=/admin/config/torch">create</a> it. NONE means it remains empty.'),
'#default_value' => torch_check_pages(config_get('torch.settings', $elname)),
'#weight' => $elweight+1,
);
$form['text']['about'][$elname.'_title'] = array(
'#type' => 'checkbox',
'#title' => t('Show title'),
'#default_value' => config_get('torch.settings', $elname.'_title'),
'#required' => FALSE,
'#weight' => $elweight+2,
);
$form['text']['contact'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#enabled'=> TRUE,
'#title' => t('Contact'),
'#group' => 'text',
);
$form['text']['contact']['details'] = array(
'#type' => 'select',
'#title' => t ('Contact page'),
'#options'=> torch_get_pages(),
'#required' => FALSE,
'#description' => t('Set this to the page you want embedded. If it's not there yet, <a href="/node/add/page?destination=/admin/config/torch">create</a> it. NONE means it remains empty.'),
'#default_value' => torch_check_pages(config_get('torch.settings', 'contact')),
'#weight' => -10,
);
$form['text']['contact']['details_title'] = array(
'#type' => 'checkbox',
'#title' => t('Show title'),
'#default_value' => config_get('torch.settings', 'details_title'),
'#required' => FALSE,
'#weight' => -9,
);
$form['text']['contact']['map'] = array(
'#type' => 'textarea',
'#title' => t ('Map Embed Code'),
'#required' => FALSE,
'#description' => t('Paste here the embed code from your map provider.'),
'#default_value' => config_get('torch.settings', 'map'),
'#weight' => -8,
);
Now if I change $form['text']['contact']
to $form['text']['cont']
then I don't have the Disabled field summary. So I know what the fix is, but what is the problem in the first place making this appear?
Comments
Can you post the full $form['text'] content? (e.g. by using dpm($form['text']) before returning the $form variable.
Thanks bro. It's pretty big, so pastebinned it
https://pastebin.com/aCE9qhRr
Is that form on a user page? In core user.admin.js we have this code:
// Contact form.
$context.find('fieldset#edit-contact').backdropSetSummary(function() {
if ($context.find('input[name="contact"]:checked').length) {
return Backdrop.t('Enabled');
}
else {
return Backdrop.t('Disabled');
}
});
Its probably the culprit somehow.
Great spotting!!
It's a form that is in an admin.inc; only specific roles that don't include the user can access it. However I have inspected the sources tab, and found the user.js is loaded, which is why this will be showing!
Wow, brilliant!