Hi,
I would like to be able to add some aria labels to field groups. The field groups are used to landmarks at my site and should be labeled with an Arial label.
I have no been able to use the API this module provides to add this functionality and I would like some pointers on how to fix that.
This is what I made as a temp hack and need some help with (it works but it's not the way to do it):
function field_group_pre_render_html5(&$element, $group, &$form) {
//dpm($group);
$id = !empty($element['#id']) ? ' id="' . $element['#id'] . '"' : '';
$aria = !empty($group->format_settings['instance_settings']['aria_label']) ? ' aria-label="' . $group->format_settings['instance_settings']['aria_label'] . '"' : '';
$class = !empty($group->classes) ? ' class="' . $group->classes . '"' : '';
$element += array(
'#type' => 'markup',
'#prefix' => '<' . $group->format_settings['instance_settings']['wrapper'] . $id . $class . $aria . '>',
'#suffix' => '</' . $group->format_settings['instance_settings']['wrapper'] . '>',
);
}
And in my own module I added this:
function hook_field_group_format_settings($group) {
// Add a wrapper for extra settings to use by others.
$form = array(
'instance_settings' => array(
'#tree' => TRUE,
'#weight' => 2,
),
);
// Add optional instance_settings.
$mode = $group->mode == 'form' ? 'form' : 'display';
switch ($group->format_type) {
case 'html5':
$form['instance_settings']['aria_label'] = array(
'#title' => t('Arial Label'),
'#type' => 'textfield',
'#default_value' => isset($group->format_settings['instance_settings']['aria_label']) ? $group->format_settings['instance_settings']['aria_label'] : $formatter['instance_settings']['aria_label'],
'#weight' => 3,);
break;
}
return $form;
}
Any help would be appreciated.
With regards, Logi
Closed: outdated
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.