This site is archived.

Drupal 7 Dynamic Forms with AJAX and #states

#states allows forms to change based on user input.
Code & Development

Presenter:

Track

Code & Development

Experience

Beginner | Intermediate | Expert

Focus

Developer

Drupal 7 Dynamic Forms with AJAX and #states

45 minutes (+15 minutes Q&A)

Room:

tags

Drupal 7 has vastly improved dynamic forms capability, and oh-so-much easier for the developer.

This session will enable you to use dynamic AJAX forms (which allow parts of the form to be rebuilt without a page load, giving your visitors an improved experience), and the new #states feature, which allows parts of a form to be shown/hidden/changed based on other parts.

Who is this for? Any developer who wants to build forms using the From API. This will be accessible to anybody who has ever seen the Drupal Form API, and there is no Javascript involved at all.

This will cover:

  • Using #ajax to build dynamic forms.
    • Example: Dependent dropdowns (like Country->Province)
    • Graceful degradation when Javascript is not available
    • Best practices
  • #states: Dynamically changing your form based on user select
  • Differences between server-side AJAX and client-side #states and when to use each

In every case we'll be showing real code that you can use to build on from the Examples for Developers project's Form Example, and AJAX Example modules.

Resources