Had stumbled into weird problem: Form API states that there is #title element, which is shown as <label> in HTML. Why it is not present in Views exposed form select element?

function THEMENAME_form_views_exposed_form_alter(&$form, &$form_state) {
  //dpm($form);
  if ($form['#id'] == 'views-exposed-form-FORMID') {
     $form['ITEMNAME']['#options']['All'] = t('My custom text');
  }
}

Works well, but if I want to replace custom text with smth like:

$form['ITEMNAME']['#options']['All'] = $form['ITEMNAME']['#title'];

It does not work. dpm($form); shows that there is no such element. So the question is:
is this a bug or there are some other ways to "extract" label?

CommentFileSizeAuthor
Capture.PNG4.63 KBPlayfulWolf
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MustangGB’s picture

Status: Active » Closed (outdated)

Closing this as outdated, feel free to re-open with updated details if it's still a problem in the latest release.