I have sort link 'Best' in exposed form. I want after user click this link, link title changes to 'New'
I'm try this, but it don't work:
function helper_form_views_exposed_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
if($form['#id']== 'views-exposed-form-pozdravleniya-taxonomy-term-page-1') {
$form['sort_by']['#title'] = '';
$form['sort_by']['#options']['created'] = '';
if ($form['sort_by']['#value'] == 'count') {
$form['sort_by']['#options']['count'] = 'New';
}
}
}
Also I'm try this, it don't work too:
function helper_form_views_exposed_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
if($form['#id']== 'views-exposed-form-pozdravleniya-taxonomy-term-page-1') {
$form['sort_by']['#title'] = '';
$form['sort_by']['#options']['created'] = '';
if ($form_state->getValue('sort_by') == 'count') {
$form['sort_by']['#options']['count'] = 'New';
}
}
}
Screenshot form dump
question from:
https://stackoverflow.com/questions/65878885/how-to-change-option-name-in-drupal-8-form-element 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…