function _name_field_instance_settings_pre_render in Name Field 7
Same name and namespace in other branches
- 6 name.admin.inc \_name_field_instance_settings_pre_render()
Themes the instance settings of the name component into a nice table, rather than a long list of individual elements.
1 call to _name_field_instance_settings_pre_render()
- name_field_instance_settings_pre_render in ./
name.module - A #pre_render function callback for formatting field instance settings.
File
- ./
name.admin.inc, line 478 - General administration functions.
Code
function _name_field_instance_settings_pre_render($form) {
$form['styled_settings'] = array(
'#prefix' => '<table>',
'#suffix' => '</table>',
'#weight' => 1,
'thead' => array(
'#prefix' => '<thead><tr><th>' . t('Field') . '</th>',
'#suffix' => '</tr></thead>',
'#weight' => 0,
),
'tbody' => array(
'#prefix' => '<tbody>',
'#suffix' => '</tbody>',
'#weight' => 1,
'title_display' => array(
'#prefix' => '<tr><td><strong>' . t('Title display') . '<sup>1</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 1,
),
'field_type' => array(
'#prefix' => '<tr><td><strong>' . t('Field type') . '<sup>2</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 2,
),
'size' => array(
'#prefix' => '<tr><td><strong>' . t('HTML size') . '<sup>3</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 3,
),
'inline_css' => array(
'#prefix' => '<tr><td><strong>' . t('Inline styles') . '<sup>4</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 4,
),
'field_override_label' => array(
'#markup' => '<tr><td colspan="7"><strong><em>' . t('Field setting overrides') . '</em></strong></td>',
'#weight' => 5,
),
'components' => array(
'#prefix' => '<tr><td><strong>' . t('Components') . '<sup>5</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 6,
),
'minimum_components' => array(
'#prefix' => '<tr><td><strong>' . t('Minimum components') . '<sup>6</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 7,
),
'labels' => array(
'#prefix' => '<tr><td><strong>' . t('Labels') . '<sup>7</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 8,
),
),
'tfoot' => array(
'#markup' => '<tfoot><tr><td colspan="7"><ol>' . '<li>' . t('The title display controls how the label of the name component is displayed in the form:<br>"%above" is the standard title;<br>"%below" is the standard description;<br>%placeholder" uses the placeholder attribute, select lists do not support this option;<br>"%hidden" removes the label.', array(
'%above' => t('above'),
'%below' => t('below'),
'%placeholder' => t('placeholder'),
'%hidden' => t('hidden'),
)) . '</li>' . '<li>' . t('The Field type controls how the field is rendered. Autocomplete is a text field with autocomplete, and the behaviour of this is controlled by the field settings.') . '</li>' . '<li>' . t('The HTML size property tells the browser what the width of the field should be when it is rendered. This gets overriden by the themes CSS properties. This must be between 1 and 255.') . '</li>' . '<li>' . t('Additional inline styles for the input element. For example, "width: 45px; background-color: #f3f3f3"') . '</li>' . '<li>' . t('Optional overrides for <em>Components</em> used. Leave all unchecked to use the field settings.') . '</li>' . '<li>' . t('Optional overrides for <em>Minimum components</em> used. Leave all unchecked to use the field settings.') . '</li>' . '<li>' . t('Optional overrides for field labels.') . '</li>' . '</ol></td></tr></tfoot>',
'#weight' => 2,
),
'extra_fields' => array(
'#weight' => 3,
),
);
$i = 0;
foreach (_name_translations() as $key => $title) {
// Adds the table header for the particullar field.
$form['styled_settings']['thead'][$key]['#markup'] = '<th>' . $title . '</th>';
$form['styled_settings']['thead'][$key]['#weight'] = ++$i;
// Strip the title & description.
unset($form['instance_size'][$key]['#description']);
unset($form['instance_size'][$key]['#title']);
$form['instance_size'][$key]['#size'] = 5;
unset($form['instance_title_display'][$key]['#description']);
unset($form['instance_title_display'][$key]['#title']);
unset($form['instance_field_type'][$key]['#description']);
unset($form['instance_field_type'][$key]['#title']);
unset($form['instance_inline_css'][$key]['#description']);
unset($form['instance_inline_css'][$key]['#title']);
unset($form['instance_labels'][$key]['#description']);
unset($form['instance_labels'][$key]['#title']);
// Moves the size element into the table.
$form['styled_settings']['tbody']['size'][$key] = $form['instance_size'][$key];
$form['styled_settings']['tbody']['size'][$key]['#prefix'] = '<td>';
$form['styled_settings']['tbody']['size'][$key]['#suffix'] = '</td>';
$form['styled_settings']['tbody']['size'][$key]['#weight'] = $i;
$form['styled_settings']['tbody']['title_display'][$key] = $form['instance_title_display'][$key];
$form['styled_settings']['tbody']['title_display'][$key]['#prefix'] = '<td>';
$form['styled_settings']['tbody']['title_display'][$key]['#suffix'] = '</td>';
$form['styled_settings']['tbody']['title_display'][$key]['#weight'] = $i;
$form['styled_settings']['tbody']['field_type'][$key] = $form['instance_field_type'][$key];
$form['styled_settings']['tbody']['field_type'][$key]['#prefix'] = '<td>';
$form['styled_settings']['tbody']['field_type'][$key]['#suffix'] = '</td>';
$form['styled_settings']['tbody']['field_type'][$key]['#weight'] = $i;
$form['styled_settings']['tbody']['inline_css'][$key] = $form['instance_inline_css'][$key];
$form['styled_settings']['tbody']['inline_css'][$key]['#prefix'] = '<td>';
$form['styled_settings']['tbody']['inline_css'][$key]['#suffix'] = '</td>';
$form['styled_settings']['tbody']['inline_css'][$key]['#weight'] = $i;
$form['styled_settings']['tbody']['labels'][$key] = $form['instance_labels'][$key];
$form['styled_settings']['tbody']['labels'][$key]['#prefix'] = '<td>';
$form['styled_settings']['tbody']['labels'][$key]['#suffix'] = '</td>';
$form['styled_settings']['tbody']['labels'][$key]['#weight'] = $i;
$form['styled_settings']['tbody']['components'][$key] = $form['instance_components'][$key];
$form['styled_settings']['tbody']['components'][$key]['#prefix'] = '<td>';
$form['styled_settings']['tbody']['components'][$key]['#suffix'] = '</td>';
$form['styled_settings']['tbody']['components'][$key]['#weight'] = $i;
$form['styled_settings']['tbody']['minimum_components'][$key] = $form['instance_minimum_components'][$key];
$form['styled_settings']['tbody']['minimum_components'][$key]['#prefix'] = '<td>';
$form['styled_settings']['tbody']['minimum_components'][$key]['#suffix'] = '</td>';
$form['styled_settings']['tbody']['minimum_components'][$key]['#weight'] = $i;
// Clean up the leftovers.
unset($form['instance_size'][$key]);
$form['instance_size']['#access'] = FALSE;
unset($form['instance_title_display'][$key]);
$form['instance_title_display']['#access'] = FALSE;
unset($form['instance_field_type'][$key]);
$form['instance_field_type']['#access'] = FALSE;
unset($form['instance_inline_css'][$key]);
$form['instance_inline_css']['#access'] = FALSE;
unset($form['instance_labels'][$key]);
$form['instance_labels']['#access'] = FALSE;
unset($form['instance_components'][$key]);
$form['instance_components']['#access'] = FALSE;
unset($form['instance_minimum_components'][$key]);
$form['instance_minimum_components']['#access'] = FALSE;
}
return $form;
}