Posts

Showing posts from October, 2014

Drupal 7 - How to make dynamic select box through Drupal #ajax framework

In Drupal 7 we often need few select boxes to be dependent themselves that means the child select box options are dependent on the parent field's selected option. A very nice example could be Country, State, City those normally has dependency. Though the trick behind Drupal 7 ajax framework is quite simple but it takes quite a time for a first timer as usual ;) . In this post, I have explained a similar example that does the same with no JS required (Drupal 7 does it behind the screen). The Example: I have a Drupal 7 vanilla instance, that has article content type by default. Article content type has 2 select box field depending on each other, Parent field called : Datatype (field_data_type) and child field called as Subdata(field_sub_data). Apart form the Durpal 7 content type config, I am using a custom module named as 'common' and only a hook_form_alter to modify the form. So, Lets start by hooking the form : The form alter: 1 2 3 4 5 6 7 8 9 10