Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Organizing collections of form elements

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:07
    In the next example, we'll take a look at building
  • 0:09
    a slightly more complex form and dealing with the form state values
  • 0:13
    in some other ways.
  • 0:15
    We're going to build another form that asks the user to input their address,
  • 0:18
    their home address, and their work address.
  • 0:21
    Once they've entered data into the form
  • 0:26
    and click the submit button,
  • 0:28
    we'll display the data that's being presented from the form
  • 0:31
    and talk about how that data is actually collected by Drupal.
  • 0:37
    Alright, so let's get started.

Organizing Collections of Form Elements

Loading...

This chapter shows how to cluster different form elements into fieldsets as well as how to expand the Forms API renderable array a tree that preserves the structure and hierarchy of the form. We'll expand the Form Fun example module and talk about the #tree property. This video uses krumo() and dsm() functions. You will need to download, install, and enable the devel module to use these functions. These functions allow you to see what variables are available to you. To accomplish the same task without using the devel module, you can add the following snippet to your module: drupal_set_message('' . print_r($vars, true) .'');

 

Note: There is a typo in the code used in this video. The function form_fun_tree() is missing a parameter, and should be as follows function form_fun_tree($form, &$form_state).

Downloads: 
Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.