You are here

public function UcAddressesExampleTextFieldHandler::getFormField in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 uc_addresses_example/handlers/uc_addresses.handlers.inc \UcAddressesExampleTextFieldHandler::getFormField()

Returns the editable field.

@access public

Parameters

array $form: The address form element.

array $form_values: An array of filled in values for one address.

Return value

array A Drupal Form API field.

Overrides UcAddressesFieldHandler::getFormField

File

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

Class

UcAddressesExampleTextFieldHandler
Handler for a simple text field.

Code

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,
    ),
  );
}