1

I have searched related questions but could't really find a decisive YES or NO.

I changed a few files in core/modules/user/ ... to alter the display of the form used on my site. For example:

 $form['account']['name'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Username'),
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#description' => $this->t(''),
      '#required' => TRUE,
      '#attributes' => [
        'class' => ['username'],
        'placeholder' => $this->t('Username'),   // ADDED THIS
        'autocorrect' => 'off',
        'autocapitalize' => 'off',
        'spellcheck' => 'false',
      ],
      '#default_value' => (!$register ? $account->getAccountName() : ''),
      '#access' => ($register || ($user->id() == $account->id() && $user->hasPermission('change own username')) || $admin),
    ];

Do these edited core files revert back to their original state thus deleting my changes when I update Drupal in the future?

1

YES, for sure. Clear enough ....?

PS: that's also why one should never hack core ...

  • Unless you use composer and composer patches, technically.. but otherwise no. – Kevin Oct 6 '17 at 13:08
  • Why not use a form alter hook? – 4k4 Oct 6 '17 at 13:19
  • Thank you, that's very clear indeed. How can I alter this form then? @4k4 suggest a form alter hook, where do I place this? – Rubenxfd Oct 6 '17 at 13:22
  • In a custom module, in a custom theme.. – Kevin Oct 6 '17 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.