You are here

class UcAddressesExampleTextFieldHandler in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 uc_addresses_example/handlers/uc_addresses.handlers.inc \UcAddressesExampleTextFieldHandler

Handler for a simple text field.

Hierarchy

Expanded class hierarchy of UcAddressesExampleTextFieldHandler

2 string references to 'UcAddressesExampleTextFieldHandler'
uc_addresses_example_uc_addresses_fields in uc_addresses_example/uc_addresses_example.module
Implements hook_uc_addresses_fields().
uc_addresses_example_uc_addresses_field_handlers in uc_addresses_example/uc_addresses_example.module
Implements hook_uc_addresses_field_handlers().

File

uc_addresses_example/handlers/uc_addresses.handlers.inc, line 11
Contains UcAddressesExampleTextFieldHandler class.

View source
class UcAddressesExampleTextFieldHandler extends UcAddressesFieldHandler {

  /**
   * Returns the editable field.
   *
   * @param array $form
   *   The address form element.
   * @param array $form_values
   *   An array of filled in values for one address.
   *
   * @access public
   * @return array
   *   A Drupal Form API field.
   */
  public function getFormField($form, $form_values) {
    $fieldName = $this
      ->getFieldName();
    $fieldValue = $this
      ->getAddress()
      ->getField($fieldName);
    $default = isset($form_values[$fieldName]) ? $form_values[$fieldName] : $fieldValue;
    return array(
      $fieldName => array(
        '#type' => 'textfield',
        '#title' => $this
          ->getFieldTitle(),
        '#default_value' => $default,
        '#required' => $this
          ->isFieldRequired(),
        '#maxlength' => 20,
        '#size' => 32,
      ),
    );
  }

  /**
   * Check to see if the field is enabled.
   *
   * @access public
   * @return boolean
   *   TRUE if the field is enabled.
   *   FALSE otherwise.
   */
  public function isFieldEnabled() {
    return TRUE;
  }

  /**
   * Check to see if the field is required.
   *
   * @access public
   * @return boolean
   *   TRUE if the field is required.
   *   FALSE otherwise.
   */
  public function isFieldRequired() {
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UcAddressesExampleTextFieldHandler::getFormField public function Returns the editable field. Overrides UcAddressesFieldHandler::getFormField
UcAddressesExampleTextFieldHandler::isFieldEnabled public function Check to see if the field is enabled. Overrides UcAddressesFieldHandler::isFieldEnabled
UcAddressesExampleTextFieldHandler::isFieldRequired public function Check to see if the field is required. Overrides UcAddressesFieldHandler::isFieldRequired
UcAddressesFieldHandler::$address private property Address object.
UcAddressesFieldHandler::$context private property The context in which this field is used.
UcAddressesFieldHandler::$definition private property The declared field definition.
UcAddressesFieldHandler::$name private property Name of this field.
UcAddressesFieldHandler::checkContext public function Checks if the field passes the context. 1
UcAddressesFieldHandler::getAddress final public function Returns the address attached to this field.
UcAddressesFieldHandler::getContext final public function Returns the context in which this field is used.
UcAddressesFieldHandler::getDefaultValue public function Returns a default value for this field. 3
UcAddressesFieldHandler::getFieldName final public function Returns the field name.
UcAddressesFieldHandler::getFieldTitle public function Returns the title to use when displaying a field. 1
UcAddressesFieldHandler::getOutputFormats public function Returns an array of possible output formats the handler supports. 3
UcAddressesFieldHandler::getProperty final public function Returns a property from the field definition.
UcAddressesFieldHandler::init protected function Can be used by subclasses to do some initialization upon construction of the object. 2
UcAddressesFieldHandler::outputValue public function Output a field's value. 3
UcAddressesFieldHandler::setValue public function Sets value in the address object.
UcAddressesFieldHandler::validateValue public function Check a fields' value. 2
UcAddressesFieldHandler::__construct final public function UcAddressesFormField object constructor.