Errata (First Edition)

This page lists the errors found in the first edition of the book.

Chapter 10. The Form API, Page 159

Location on the page: 
last paragraph
Error: 

#markup

Correction: 

markup

Description of the Error: 

The value of the form property #type should be markup instead of #markup (as in the listing below that paragraph).

Chapter 10. The Form API, Page 162

Location on the page: 
Title: "Call Order of Theme, Validation, and Submission Functions"
Error: 

The form definition has set the optional $form['#base'] property to foo.

The book states that Drupal will look for theme functions called:

bluebeach_formexample_foo()
phptemplate_formexample_foo()
theme_formexample_foo()

These functions are incorrectly named, because drupal will look for "theme name" plus $form['#base']

The same issue with the validation and sumission functions:

formexample_foo_validate()
formexample_foo_submit()

Correction: 


bluebeach_foo()
phptemplate_foo()
theme_foo()

And for the validation en submission functions:


foo_validate()
foo_submit()

Description of the Error: 

incorrectly named functions

Chapter 10. The Form API, Page 163

Location on the page: 
Passing Data Along with form_set_value() section.
Error: 

Omission of the $form argument in the hook_validate() sig if you are using form_set_value().

Correction: 

Show the needed $form argument in the _validate() signature:
_validate($form_id, $form_values, $form) {
...

Description of the Error: 

It would be helpful to show how the $form variable became available in the form_set_value() statement.

Chapter 10. The Form API, Page 165

Location on the page: 
1st Paragraph
Error: 

if (!in_array($element['#value'], $allowed_flavors) {

Correction: 

if (!in_array($element['#value'], $allowed_flavors)) {

Description of the Error: 

Code error, missing right bracket.

Chapter 10. The Form API, Page 165

Location on the page: 
1st Paragraph
Error: 

form_error($element, t('You must enter spicy or sweet.');

Correction: 

form_error($element, t('You must enter spicy or sweet.'));

Description of the Error: 

Form_error missing right bracket.

Chapter 10. The Form API, Page 165

Location on the page: 
Last paragraph and example
Error: 

Unlike the other hooks in this section, the form_alter hook takes just the module name as a prefix, not the form name. Thus, the function's signature is modulename_form_alter($form_id, &$form).

Description of the Error: 

Clarification

Chapter 10. The Form API, Page 167

Location on the page: 
Last item defined in formwizard_menu()
Error: 

'access' => user_access('access_content')

Correction: 

'access' => user_access('access content')

Description of the Error: 

The access content permission is not written with an underscore.

Chapter 10. The Form API, Page 172

Location on the page: 
#pre_render examples
Error: 

Incorrect function signatures for foo($form_id, $form) and bar($form_id, $form)

Correction: 

The signatures should have references to the $form variable:
foo($form_id, &$form) and
bar($form_id, &$form)

Description of the Error: 

Missing reference markers.

Chapter 10. The Form API, Page 175

Location on the page: 
listing of $form['pet_weight']
Error: 

#after_field

Correction: 

#field_suffix

Description of the Error: 

#after_field is not a valid property, #field_suffix is the right one.

Chapter 10. The Form API, Page 176

Location on the page: 
Password element subheading
Error: 

Properties commonly used with the password element are #attributes, #default_value, #description ...

Correction: 

Properties commonly used with the password element are #attributes, #description ...

Description of the Error: 

#default_value is not a valid property of the password element. See: http://drupal.org/node/67519