Skip to content

Instantly share code, notes, and snippets.

@vyasamit2007
Created April 10, 2017 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vyasamit2007/d9310fda83c79002e6af6032bc89e4e5 to your computer and use it in GitHub Desktop.
Save vyasamit2007/d9310fda83c79002e6af6032bc89e4e5 to your computer and use it in GitHub Desktop.
Task-13 Add a field to an existing form
<?php
/**
* @file
* Add a field to an existing form.
*/
use \Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_FORM_ID_alter().
*/
function lotus_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Add a checkbox to registration form for terms.
$form['terms'] = array(
'#type' => 'checkbox',
'#title' => t("I accept the website's terms."),
'#required' => TRUE,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment