Created
April 10, 2017 18:48
-
-
Save vyasamit2007/d9310fda83c79002e6af6032bc89e4e5 to your computer and use it in GitHub Desktop.
Task-13 Add a field to an existing form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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