You are here

function phone_widget_settings in Phone 6

Same name and namespace in other branches
  1. 5 phone.module \phone_widget_settings()

Implementation of hook_widget_settings().

Handle the parameters for a widget.

Parameters

$op: The operation to be performed. Possible values:

  • "form": Display the widget settings form.
  • "validate": Check the widget settings form for errors.
  • "save": Declare which pieces of information to save back to the database.

$widget: The widget on which the operation is to be performed.

Return value

This varies depending on the operation.

  • "form": an array of form elements to add to the settings page.
  • "validate": no return value. Use form_set_error().
  • "save": an array of names of form elements to be saved in the database.

File

./phone.module, line 697
Defines phone number fields for CCK. Provide some verifications on the phone numbers

Code

function phone_widget_settings($op, $widget) {
  switch ($op) {
    case 'form':
      $form = array();
      $size = isset($widget['size']) && is_numeric($widget['size']) ? $widget['size'] : 60;
      $form['input']['size'] = array(
        '#type' => 'textfield',
        '#title' => t('Size of textfield'),
        '#default_value' => $size,
        '#element_validate' => array(
          '_element_validate_integer_positive',
        ),
        '#required' => TRUE,
      );
      return $form;
    case 'validate':
      break;

    //do nothing
    case 'save':
      return array(
        'size',
      );
  }
}