handler_form.inc 2.67 KB
Newer Older
Cody Craven's avatar
Cody Craven committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
// $Id$

/**
 * Abstract class to act as the taxonomy display plugins form handing.
 *
 * The $form and $form_state parameters listed within this section are not true
 * $form and $form_state but rather a fieldset and form_state['values'] for the
 * fields in that fielset.
 */
abstract class TaxonomyDisplayHandlerForm {
  /**
   * Prepare the form that users will configure.
   *
   * @param array $form
   *   A fieldset for configuration to display to the user for this handler.
17
18
19
20
21
22
   * @param array $values
   *   The values from the sub-form taken from $form_state, note any alterations
   *   will affect the values in $form_state.
   * @param mixed $options
   *   The data that was stored on behalf of the handler resulting from the
   *   return of the TaxonomyDisplayHandlerForm::formSubmit implementation.
Cody Craven's avatar
Cody Craven committed
23
24
   *
   * @return TaxonomyTermDisplayHandler
25
26
   *
   * @see TaxonomyDisplayHandlerForm::formSubmit()
Cody Craven's avatar
Cody Craven committed
27
   */
28
  abstract public function formFieldset(&$form, &$values, $options = NULL);
Cody Craven's avatar
Cody Craven committed
29
30
31
32
33

  /**
   * Perform any processing desired and return the result to be stored.
   *
   * @param array $form
34
35
36
37
   *   A fieldset containing the sub-form rendered to the user.
   * @param array $values
   *   The values from the sub-form taken from $form_state, note any alterations
   *   will affect the values in $form_state.
Cody Craven's avatar
Cody Craven committed
38
39
40
41
   *
   * @return mixed
   *   Any single variable or no variable can be returned. Whatever is returned
   *   will be stored on behalf of the plugin for later use.
42
43
   *
   * @see TaxonomyDisplayHandlerForm::formFieldset()
Cody Craven's avatar
Cody Craven committed
44
   */
45
46
47
48
49
  public function formSubmit($form, &$values) {
    // Override formSubmit in your implementing handler if any data is to be
    // stored on behalf of your handler on submit.
    return;
  }
Cody Craven's avatar
Cody Craven committed
50
51
52
53
54
55
56
57

  /**
   * Perform validation on the custom formFieldset when the user submits.
   *
   * This method does not need to be defined in the implementing class as
   * validation can be skipped in some cases.
   *
   * @param array $form
58
59
60
61
   *   A fieldset containing the sub-form rendered to the user.
   * @param array $values
   *   The values from the sub-form taken from $form_state, note any alterations
   *   will affect the values in $form_state.
Cody Craven's avatar
Cody Craven committed
62
63
   *
   * @return TaxonomyTermDisplayHandler
64
65
   *
   * @see TaxonomyDisplayHandlerForm::formFieldset()
Cody Craven's avatar
Cody Craven committed
66
   */
67
  public function formValidate($form, &$values) {
Cody Craven's avatar
Cody Craven committed
68
69
    // Override formValidate in your implementing handler if any validation work
    // is to be done.
70
71
72
73
74
75
    
    if (FALSE) {
      // This is an example of how you can set an error on one of your form
      // elements with the key 'example_element'.
      form_set_error(implode('][', $form['example_element']['#parents']), t('Error message'));
    }
Cody Craven's avatar
Cody Craven committed
76
77
    return $this;
  }
78
}