function termcase_form_taxonomy_form_term_alter in Termcase 8
Same name and namespace in other branches
- 7 termcase.module \termcase_form_taxonomy_form_term_alter()
Implements hook_form_FORM_ID_alter().
File
- ./
termcase.module, line 26 - The Termcase module gives you the option to specify specific case-formatting on terms.
Code
function termcase_form_taxonomy_form_term_alter(&$form, FormStateInterface $form_state) {
$edit_link = t('You can change this setting on the <a href="@vocabulary_edit_link">vocabulary settings page</a>.', [
'@vocabulary_edit_link' => url('admin/structure/taxonomy/' . $form['#vocabulary']->machine_name . '/edit'),
]);
$termcase = _termcase_vocabulary_termcase($form['#vocabulary']->machine_name);
switch ($termcase) {
case TERMCASE_UCFIRST:
$form['name']['#description'] = t('Please note: the first letter of this term will be converted to <em>Uppercase</em>.') . ' ' . $edit_link;
break;
case TERMCASE_LOWERCASE:
$form['name']['#description'] = t('Please note: the term will be converted to <em>lowercase</em>.') . ' ' . $edit_link;
break;
case TERMCASE_UPPERCASE:
$form['name']['#description'] = t('Please note: the term will be converted to <em>UPPERCASE</em>.') . ' ' . $edit_link;
break;
case TERMCASE_PROPERCASE:
$form['name']['#description'] = t('Please note: the term will be converted to <em>Proper Case</em>.') . ' ' . $edit_link;
break;
}
}