Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public function getFormId()
  2. {
  3. return 'registration_form';
  4. }
  5.  
  6. public function buildForm(array $form, FormStateInterface $form_state)
  7. {
  8. $form['registration_form']['lastname'] = [
  9. '#type' => 'textfield',
  10. '#title' => $this->t('lastname'),
  11. '#required' => FALSE,
  12. '#default_value' => (isset($profile->lastname)) ? $profile->lastname : '',
  13. '#prefix' => '<div class="form-group">',
  14. '#suffix' => '</div>',
  15. ];
  16. }
  17.  
  18. public function validateForm(array &$form, FormStateInterface $form_state)
  19. {
  20. /* if (!$form_state->getValue('firstname') || empty($form_state->getValue('firstname'))) {
  21. $form_state->setErrorByName('firstname', $this->t('firstname is required'));
  22. }
  23. }
  24.  
  25. public function submitForm(array &$form, FormStateInterface $form_state)
  26. {
  27. Redirection;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement