Hello,

In one of my views, I set the fields as a filter. I now resize the size of those above. To do this, I would have found the function to act on these fields.

The attached image should help you better understand my problem ...

Thank you in advance for your help.

CommentFileSizeAuthor
img_2.jpg48.57 KBClément

Comments

Clément’s picture

I just found the solution: use css but still it might be interesting to know the code, which would allow myself, for example, rename fields, etc..

merlinofchaos’s picture

Status: Active » Fixed

You can use hook_form_alter() to modify the form.

Clément’s picture

Thank you for your reply, I'll try it.

Greetings.
Clement

Clément’s picture

I found the solution with form_views_exposed_form_alter:

<?php
function MODULE_NAME_form_views_exposed_form_alter(&$form, $form_state) {
  if ($form['#id'] == 'ID') {
    $form['FIELD_NAME']['min']['#size'] = 5;
    $form['FIELD_NAME']['max']['#size'] = 5;
  }
}
?>
somebodysysop’s picture

Where do I find the form ID?:

 if ($form['#id'] == 'ID') {

I read somewhere it is referred to as the views-exposed-form-view-id-display-id, but I have yet to discover how to find it. Can anyone help, please?

merlinofchaos’s picture

It is just views_exposed_form but you can then check $form_state['view'] to see which view it is.

somebodysysop’s picture

Thanks. Found it using:

drupal_set_message('

'. print_r($form, TRUE) .'

');

and, searching for #ID. An it is views_exposed_form.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

noocx’s picture

You can find it in the page source if you inspect the form:

<form id="views-exposed-form-YOURVIEWNAME-YOURDISPLAY"..

or from PHP:

dsm($form['#id']);

appbros’s picture

Where did you find the file to edit this form? I really need to fix this problem so any help would be great. Same exact problem as you.

ragavendra_bn’s picture

Issue summary: View changes

@Clément -- Can you show the css change you made as I also need to make a similar one. I tried like adding below in the style.css but no luck. Thanks in advance.

/* -----------Views Exposed FIlters ------- */

#views-exposed-form-front-page input.form-text {
  width:2px; // choose a number of pixels
  size:10;
  font-style: italic;
}
ragavendra_bn’s picture

Never mind, I figured out the css part as it needs to be in style.css for the bartik theme users. Yet would be nice to know as to where to put it in the MODULE_NAME_form_views_exposed_form_alter

gshreegs’s picture

#12, you can add this in the .module file of your module folder. This is the file we use to add the hook_form_alters, and other hooks.