By ludo1960 on
Hi,
I have a views exposed form and I am trying to target the form id, getting confused!
From what I have read "inspect HTML to get the form ID"
<form id="views-exposed-form-patient-search-page-1" method="get" accept-charset="UTF-8" action="/cortex/patient">
So from what I have read 'views-exposed-form-patient-search-page-1' should be the form id, this don't work!
Tried 'views_exposed_form_patient_search_page_1' Still no luck!
Any ideas where I'm going wrong?
Comments
If I am implementing
If I am implementing hook_form_alter, I temporarily have add the line
drupal_set_message("Form Id: $form_id")and visit the page in question. The devel module is also useful in this regard.Thanks Nevets
OK, so I have an exposed view and created a menu path for the page display, I tried the code in the view header, but all I get is "Form Id: "
I have the devel module Development block enabled, but I'm not sure which option to use to find the form_id
The code expects to be in an
The code expects to be in an implementation of hook_form_alter() which would be part of a module.
Got it
Thanks again Nevets,,u da man!
Check
Check out
http://www.lullabot.com/articles/modifying-forms-5-and-6
Specifically the section "Find the form ID"
Thanks
Jim, the info there on find the form id was just as I originally posted, ie look at the html source. To my cost I have found out that it is not always the case, Nevet's code works a treat!
hello, I was wondering what
hello,
I was wondering what the form id ending up being?
As you mentioned this code does not work:
function project_extras_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'views_exposed_form_search_page_1' :
This code works but it affects all exposed forms on the site.
function project_extras_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'views_exposed_form' :
Could you please help me to target just the view search or view search page 1.
Thank you!
When posting code, please us
When posting code, please us the code tags to make it easier to read for us!
The answer to your question is already in this thread see http://drupal.org/node/672688#comment-2428084
You can use logic like if (
You can use logic like
You will need to change name ('colors') and display ('page_1') to reflect your actual view.
thanks nevets! your code
thanks nevets! your code above worked perfectly =)
Thanks Nevets for you
Thanks Nevets for you solution, it works with me in Drupal 7.
Regards,
Easiest Way to Find Views Exposed Form ID
Paste this code inside your template.php. It's should give you the form id of the views exposed form.