0

I need the checkboxes labels exposed in views search pages to be different than the checkboxes labels displayed in the node/xx/edit forms.

I found the same documentation everywhere about the way to change the label of a submit button using a template.php function (works fine) :

function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
  if ($vars['form']['#id'] == 'views-exposed-form-XXX') {
    $vars['form']['submit']['#value'] = 'gagarine' ;
    unset($vars['form']['submit']['#printed']);
    $vars['button'] = drupal_render($vars['form']['submit']);
  }
}

I can't find any accurate documentation to rename a cck field label when exposed in a search page.

edit² : cleaning the thread for relative readability since I got something working

1 Answer 1

1

ok I came to this : this looks like it does the job. maybe this could be rewieved by a DOCUMENTED drupal hacker.

function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
  // only alter the jobs search exposed filter form
  if ($vars['form']['#id'] == 'views-exposed-form-MYFORMID') {

    // change the text of an exposed field label (BEF checkboxes here)
    $vars['form'][FIELDNAMEasinurl]['#options'][0] = 'a different label in search pages' ;
    $vars['form'][FIELDNAMEasinurl]['#options'][1] = 'than in edit forms' ;
    // this particular field has a common layout not the case here :
    // this will work but not with the BEF checkboxes layout I want
    //$vars['widgets'][FIELDNAMEinternal]->widget = drupal_render($vars['form']['partage']);

    // or the field was rendered by better exposed filters (here cheboxes)
    // search into better_exposed_filters.theme the function call you need (theme_select_as..)
    $vars['widgets'][FIELDNAMEinternal]->widget = theme_select_as_checkboxes_fieldset($vars['form']['partage']);

    // Change the text on the submit button
    // [...]

  }

Your Answer

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

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