Skip to content

Instantly share code, notes, and snippets.

@gauravgoyal
Last active April 11, 2018 08:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gauravgoyal/809b13e2901ef4a4c9bb8472ca60a385 to your computer and use it in GitHub Desktop.
Save gauravgoyal/809b13e2901ef4a4c9bb8472ca60a385 to your computer and use it in GitHub Desktop.
Task-11: Alter an existing simple form
<?php
/**
* @file
* Change the label of Comment form button to 'Add Comment'
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_alter().
*/
function example_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'comment_comment_form') {
$form['actions']['submit']['#value'] = t('Add Comment');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment