How to change Drupal 8 Core Contact form fleld label :-
If you want to change Contact form "Message" field label you can use "hook_form_alter" .
either you can create a custom module or either you can add form alter in your theme file also.
Add placeholder in default search using form alter
If you want to change Contact form "Message" field label you can use "hook_form_alter" .
either you can create a custom module or either you can add form alter in your theme file also.
function your_theme_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if ($form_id == 'contact_message_feedback_form') {
$form['message']['widget'][0]['value']['#title'] = t("My Custom Body Label");
}
}
Add placeholder in default search using form alter
function your_theme_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if (in_array($form_id, ['search_block_form', 'search_form'])) {
$form['keys']['#attributes']['placeholder'] = t('Search...');
}
}if ($form_id == 'contact_message_feedback_form') {
$form['actions']['submit']['#value'] = t("My Altered submit button text here");
$form['subject']['widget'][0]['value']['#title'] = t ("My Altered title here");
$form['message']['widget'][0]['value']['#title'] = t("My custom body text here");
//$form['message']['widget'][0]['value']['#title'] = t("My Custom Body Label");
$form['#suffix'] = "<div class='extra-text'><p>Show some text before the comment form.</p></div>";
}
}
No comments:
Write comments