drupal7

Disable elements on drupal webform

Drupal 8 provides an easy way to simply edit the component or element on the drupal webform and disable elements using the checkbox displayed on the form.

 

disable elements

However, there could be different scenarios where we might need to disable few elements on specific cases that might not available on drupal webform conditional. Eg - Disable elements for certain user roles.

Reload parent page after AJAX modal popup is closed.

Modal popup window is more elegant way of showing information to the user in views,webform, etc. We can also insert an ajax modal popup link for a webform in a global text field of a view. When the view is rendered, the link is displayed to display the webform in an ajax dialog box, but many a times, when the webform is filled with newer values and saved on the ajax itself, the parent page, in this case, the view, is not refreshed to show the updated values in the form.

Set default value for datepicker using jQuery in Drupal

Datepicker in drupal is rendered as separate select elements for day, month and year by default which makes it difficult to set a default value if we want to set it to some string value, eg. today, +2 months, etc. This page is to check how we can set default value for datepicker using a simple jQuery.

Get string from PHP

Consider you have the above string value. If you are sending this value from a php code, convert it to a date format using strtotime().

Hidden Element not submitted on Drupal Form

Hidden elements can be easily created on a Drupal form. When the form is submitted, $form_state variable seems to be holding the value of this element in various hooks, "form_alter", "validate", etc.

Note that if you have an ajax call or a jquery code which assigns or modifies the value of the hidden element, this value will not be sent when the form is submitted. For eg, An hidden element is created from -