You are here

function sms_sendtophone_widget in SMS Framework 6

Same name and namespace in other branches
  1. 5 modules/sms_sendtophone/sms_sendtophone.module \sms_sendtophone_widget()
  2. 6.2 modules/sms_sendtophone/sms_sendtophone.module \sms_sendtophone_widget()
  3. 7 modules/sms_sendtophone/sms_sendtophone.module \sms_sendtophone_widget()

Implementation of hook_widget().

File

modules/sms_sendtophone/sms_sendtophone.module, line 271

Code

function sms_sendtophone_widget($op, &$node, $field, &$items, $delta = NULL) {
  switch ($op) {
    case 'form':
      $form = array();
      $form[$field['field_name']] = array(
        '#tree' => TRUE,
      );
      if ($field['widget']['rows'] == 1) {
        $form[$field['field_name']][0]['value'] = array(
          '#type' => 'textfield',
          '#title' => t($field['widget']['label']),
          '#default_value' => isset($items[0]['value']) ? $items[0]['value'] : '',
          '#required' => $field['required'],
          '#description' => t($field['widget']['description']),
          '#maxlength' => $field['max_length'] ? $field['max_length'] : NULL,
          '#weight' => $field['widget']['weight'],
        );
      }
      else {
        $form[$field['field_name']][0]['value'] = array(
          '#type' => 'textarea',
          '#title' => t($field['widget']['label']),
          '#default_value' => $items[0]['value'],
          '#required' => $field['required'],
          '#rows' => $field['widget']['rows'],
          '#description' => t($field['widget']['description']),
          '#weight' => $field['widget']['weight'],
        );
      }
      return $form;
  }
}