I am following https://www.drupal.org/docs/8/api/form-api/introduction-to-form-api for my hello world module.
Below is my code
namespace Drupalhello_worldForm; use DrupalCoreFormFormBase; use DrupalCoreFormFormStateInterface; /** * Implements an hello_world form. */ class HelloWorldForm extends FormBase { /** * {@inheritdoc} */ public function getFormId() { return 'hello_world_form'; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form['phone_number'] = array( '#type' => 'tel', '#title' => $this->t('Your phone number'), ); $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( '#type' => 'submit', '#value' => $this->t('Save'), '#button_type' => 'primary', ); return $form; } function hello_world_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) { if ($form_id == 'hello_world_form') { $form['phone_number']['#description'] = t('Start with + and your country code.'); } } }
I also cleated cache. Not sure why form is not altering.
Sponsored by SupremePR