function _name_field_settings_pre_render in Name Field 6
Same name and namespace in other branches
- 7 name.admin.inc \_name_field_settings_pre_render()
Themes the global field settings of the name component into a nice table, rather than a long list of individual elements.
1 call to _name_field_settings_pre_render()
File
- ./
name.admin.inc, line 424 - General administration functions.
Code
function _name_field_settings_pre_render($form) {
$warning = t('<strong>Warning! Changing this setting after data has been created could result in the loss of data!</strong>');
$form['field_properties'] = 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,
'components' => array(
'#prefix' => '<tr><td><strong>' . t('Components') . ' <sup>1</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 1,
),
'minimum_components' => array(
'#prefix' => '<tr><td><strong>' . t('Minimum components') . ' <sup>2</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 2,
),
'max_length' => array(
'#prefix' => '<tr><td><strong>' . t('Maximum length') . ' <sup>3</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 3,
),
'labels' => array(
'#prefix' => '<tr><td><strong>' . t('Labels') . ' <sup>4</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 4,
),
'sort_options' => array(
'#prefix' => '<tr><td><strong>' . t('Sort options') . ' <sup>5</sup></strong></td>',
'#suffix' => '</tr>',
'#weight' => 5,
),
),
'tfoot' => array(
'#value' => '<tfoot><tr><td colspan="6"><ol>' . '<li>' . t('Only selected components will be activated on this field. All non-selected components / component settings will be ignored.') . '<br/>' . $warning . '</li>' . '<li>' . t('The minimal set of components required before considered the name field to be incomplete.') . '</li>' . '<li>' . t('The maximum length of the field in characters. This must be between 1 and 255.') . '<br/>' . $warning . '</li>' . '<li>' . t('The labels are used to distinguish the fields. You can use the special label "!tag" to hide this.', array(
'!tag' => '<none>',
)) . '</li>' . '<li>' . t('This enables sorting on the options after the vocabulary terms are added and duplicate values are removed.') . '</li>' . '</ol></td></tr></tfoot>',
'#weight' => 2,
),
);
$i = 0;
foreach (_name_translations() as $key => $title) {
// Adds the table header for the particullar field.
$form['field_properties']['thead'][$key]['#value'] = '<th>' . $title . '</th>';
$form['field_properties']['thead'][$key]['#weight'] = ++$i;
// Strip the title & description.
unset($form['components'][$key]['#description']);
unset($form['components'][$key]['#title']);
unset($form['minimum_components'][$key]['#description']);
unset($form['minimum_components'][$key]['#title']);
unset($form['max_length'][$key]['#description']);
unset($form['max_length'][$key]['#title']);
$form['max_length'][$key]['#size'] = 10;
unset($form['labels'][$key]['#description']);
unset($form['labels'][$key]['#title']);
$form['labels'][$key]['#size'] = 10;
if (isset($form['sort_options'][$key])) {
unset($form['sort_options'][$key]['#description']);
unset($form['sort_options'][$key]['#title']);
}
// Moves the elements into the table.
$form['field_properties']['tbody']['components'][$key] = $form['components'][$key];
$form['field_properties']['tbody']['components'][$key]['#prefix'] = '<td>';
$form['field_properties']['tbody']['components'][$key]['#suffix'] = '</td>';
$form['field_properties']['tbody']['components'][$key]['#weight'] = $i;
$form['field_properties']['tbody']['minimum_components'][$key] = $form['minimum_components'][$key];
$form['field_properties']['tbody']['minimum_components'][$key]['#prefix'] = '<td>';
$form['field_properties']['tbody']['minimum_components'][$key]['#suffix'] = '</td>';
$form['field_properties']['tbody']['minimum_components'][$key]['#weight'] = $i;
$form['field_properties']['tbody']['max_length'][$key] = $form['max_length'][$key];
$form['field_properties']['tbody']['max_length'][$key]['#prefix'] = '<td>';
$form['field_properties']['tbody']['max_length'][$key]['#suffix'] = '</td>';
$form['field_properties']['tbody']['max_length'][$key]['#weight'] = $i;
$form['field_properties']['tbody']['labels'][$key] = $form['labels'][$key];
$form['field_properties']['tbody']['labels'][$key]['#prefix'] = '<td>';
$form['field_properties']['tbody']['labels'][$key]['#suffix'] = '</td>';
$form['field_properties']['tbody']['labels'][$key]['#weight'] = $i;
if (isset($form['sort_options'][$key])) {
$form['field_properties']['tbody']['sort_options'][$key] = $form['sort_options'][$key];
}
else {
$form['field_properties']['tbody']['sort_options'][$key] = array(
'#value' => ' ',
);
}
$form['field_properties']['tbody']['sort_options'][$key]['#prefix'] = '<td>';
$form['field_properties']['tbody']['sort_options'][$key]['#suffix'] = '</td>';
$form['field_properties']['tbody']['sort_options'][$key]['#weight'] = $i;
// Clean up the leftovers.
unset($form['components'][$key]);
$form['components']['#access'] = FALSE;
unset($form['minimum_components'][$key]);
$form['minimum_components']['#access'] = FALSE;
unset($form['max_length'][$key]);
$form['max_length']['#access'] = FALSE;
unset($form['labels'][$key]);
$form['labels']['#access'] = FALSE;
if (isset($form['sort_options'][$key])) {
unset($form['sort_options'][$key]);
$form['sort_options']['#access'] = FALSE;
}
}
// Move the additional options under the table.
$form['extra_fields'] = array(
'#weight' => 2,
);
$form['title_options']['#weight'] = 0;
$form['generational_options']['#weight'] = 1;
$form['extra_fields']['title_options'] = $form['title_options'];
$form['extra_fields']['generational_options'] = $form['generational_options'];
unset($form['title_options']);
unset($form['generational_options']);
return $form;
}