I have a form that I want to override title of textfield. I managed to do that with this snippet in _form_alter function

$form['some_wrapper']['email'] = [
  '#type' => 'textfield',
  '#title' => t('Change this title'),

Wondering if i could just override this with some method like setValue?

  • 2
    Do you mean $form['some_wrapper']['email']['#title'] = t('Change this title');?
    – Clive
    Feb 4, 2019 at 15:47
  • Well I guess it can be done like that also, but I was wondering if this can/needs to be done with some method or is it made like old school D7 way.
    – Blissful
    Feb 4, 2019 at 16:14
  • 2
    Render arrays are still just arrays, they haven't been classed in D8 (too complicated; though I wouldn't bet against someone trying to get it classed for D9/10)
    – Clive
    Feb 4, 2019 at 16:28


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.