I have a view with 2 exposed filters . one is the start date and the other is the end date. I need to programatically control the end date filter based on a checkbox. I added a checkbox to the exposed form in the form_alter hook. I implemented views_query_alter hook to update the expiry date value based on the state of the checkbox. This works as expected so far.

The problem is with the display of the checkbox in subsequent displays of the page(Ex: Pagination or submit exposed form). I need to get the submitted value of the checkbox and display it as checked or unchecked accordingly. I am unable to get the value submitted for the checkbox using the variables $form and $form_state.

Can someone help me in getting the submitted value for a custom field in hook_form_alter?

Link to a similar issue. Not sure if the solution provided here works.

  • You can get the value using $_GET['checkboxname'], if you are passing it using URL? – Sumit Madan May 27 '15 at 10:30
  • Thanks Sumit! Your comment helped me realize that getting the parameter is not my issue. The issue is with setting the default value to the checkbox and display it as checked or unchecked. Not sure why it doesnt work. – Bhuvana May 28 '15 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.