SHARE
TWEET

Untitled

a guest Jun 25th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace Drupalbusiness_listingForm;
  4.  
  5. use DrupalCoreFormFormStateInterface;
  6. use DrupaluserRegisterForm;
  7.  
  8. /**
  9.  * Provides a user login form.
  10.  */
  11. class NewUserRegisterForm extends RegisterForm {
  12.  
  13.     /**
  14.      * {@inheritdoc}
  15.      */
  16.     public function form(array $form, FormStateInterface $form_state) {
  17.  
  18.         $form = parent::form($form, $form_state);
  19.  
  20.         // Change the form here
  21.         $form['test'] = [
  22.           '#markup' => '<p>Test extended form</p>',
  23.         ];
  24.         return $form;
  25.     }
  26.  
  27. // uncommenting submit results in error
  28. //  public function submitForm(array &$form, FormStateInterface $form_state) {
  29.  
  30. //      get the created users uuid & perform additional database queries
  31.  
  32. //  }
  33.      
  34. /**
  35.  * Implements hook_entity_build
  36.  */
  37. function business_listing_entity_type_build(array &$entity_types) {
  38.     $entity_types['user']->setFormClass('business_listing_register', 'Drupalbusiness_listingFormNewUserRegisterForm');
  39. }
  40.      
  41. public function register() {
  42.     $build = [];
  43.  
  44.     $entity = Drupal::entityManager()
  45.         ->getStorage('user')
  46.         ->create(array());
  47.  
  48.     $formObject = Drupal::entityManager()
  49.         ->getFormObject('user', 'business_listing_register')
  50.         ->setEntity($entity);
  51.  
  52.     $build['form'] = Drupal::formBuilder()->getForm($formObject);
  53.     return $build;
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top