In my drupal 7 site I want to remove an apply button in form I created in Views (Exposed form in block = Yes). I tried this in my template.php:
function myproject_preprocess_views_exposed_form(&$vars, $hook) {
dpm($vars);
if ($vars['form']['#id'] == 'views-exposed-form-search-page') {
// Remove the submit button ??
unset($vars['form']['submit']);
}
}
... but that does not work. Can any one point me in the right direction? //Tommy EDITED: I now succeeded in removing the button, with this snippet:
function myproject_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
if ($form['#id'] == 'views-exposed-form-search-page') {
// submit on enter
// Remove the submit button ??
unset($form['submit']);
}
}
... so what I need now is how to submit the form on enter. I keep trying.
I complicated this too much. Just hiding the button with CSS with:
.views-submit-button{ display:none; }
... and everything worked as it was supposed to.
For drupal 8 peeps, here is how to hide the button:
function template_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
if ($form['#id'] == 'views-exposed-form-products-page-1') {
// Remove the submit button
unset($form['actions']['submit']);
}
}