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' ;
    $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


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
    // [...]

|improve this answer|||||

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.