You are here

class UCXF_AddressField in Extra Fields Checkout Pane 6.2

Same name and namespace in other branches
  1. 7 class/UCXF_AddressField.class.php \UCXF_AddressField

Class for a Extra Fields Pane Address field

Address fields are shown on checkout and on the order administration pages in the delivery and billing panes provided by Ubercart.

Hierarchy

Expanded class hierarchy of UCXF_AddressField

File

class/UCXF_AddressField.class.php, line 13
Contains the UCXF_AddressField class.

View source
class UCXF_AddressField extends UCXF_Field {

  // -----------------------------------------------------------------------------
  // CONSTRUCT
  // -----------------------------------------------------------------------------

  /**
   * UCXF_AddressField object constructor
   * @access public
   * @return void
   */
  public function __construct() {
    parent::__construct();
    $this->returnpath = 'admin/store/settings/checkout/edit/fields';
    $this->pane_types = array(
      'extra_delivery',
      'extra_billing',
    );
  }

  // -----------------------------------------------------------------------------
  // FORMS
  // -----------------------------------------------------------------------------

  /**
   * Override of UCXF_Field::edit_form().
   *
   * Get the edit form for the item.
   *
   * @access public
   * @return array
   */
  public function edit_form() {
    $form = parent::edit_form();

    // Unset pane type field, the pane types asking is handled differently
    unset($form['ucxf']['pane_type']);

    // Unset also weight field, because the weight for an address field is implemented differently
    unset($form['ucxf']['weight']);

    // Add form element to ask in which panes they need to appear
    $form['ucxf']['panes'] = array(
      '#title' => t('Select the panes the field must get into'),
      '#type' => 'checkboxes',
      '#options' => array(
        'extra_delivery' => t('Delivery pane'),
        'extra_billing' => t('Billing pane'),
      ),
      '#weight' => 5,
      '#default_value' => $this->pane_types,
    );
    return $form;
  }

  /**
   * Override of UCXF_Field::edit_form_submit().
   *
   * Submit the edit form for the item.
   *
   * @param array $form
   * @param array $form_state
   * @access public
   * @return void
   */
  public function edit_form_submit($form, &$form_state) {
    $field = $form_state['values']['ucxf'];

    // Check if user wants field in both delivery and billing pane
    // only delivery pane = 'extra_delivery'
    // only billing pane = 'extra_billing'
    // both panes = 'extra_delivery|extra_billing'
    foreach ($field['panes'] as $pane_type) {
      if ($pane_type) {
        $form_state['values']['ucxf']['pane_type'][$pane_type] = $pane_type;
      }
    }
    parent::edit_form_submit($form, $form_state);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UCXF_AddressField::edit_form public function Override of UCXF_Field::edit_form(). Overrides UCXF_Field::edit_form
UCXF_AddressField::edit_form_submit public function Override of UCXF_Field::edit_form_submit(). Overrides UCXF_Field::edit_form_submit
UCXF_AddressField::__construct public function UCXF_AddressField object constructor @access public Overrides UCXF_Field::__construct
UCXF_Field::$display_settings private property An array of page names on which the field may be displayed @access private
UCXF_Field::$pane_types private property An array of pane types the field is in. @access private
UCXF_Field::delete public function Delete the field from the database. @access public
UCXF_Field::edit_form_validate public function Validate the edit form for the item.
UCXF_Field::from_array function Load an existing item from an array. @access public
UCXF_Field::generate public function generate() Generates a field array used in forms generated by uc_extra_fields_pane @access public
UCXF_Field::generate_value public function Generates the value for use in fields. This value will be used as a default value for textfields and as an array of options for selection fields.
UCXF_Field::get_example public static function Returns an example for the value section
UCXF_Field::get_value_type public function Returns the "readable" value type, as a string.
UCXF_Field::in_pane public function Returns if field is in given pane
UCXF_Field::may_display public function Returns if the field's value may be displayed on te given page.
UCXF_Field::output public function Output a value with filtering
UCXF_Field::output_value public function Output a value based on the field type
UCXF_Field::save public function save() Saves field in database @access public
UCXF_Field::to_array public function Return as an array of values. @access public
UCXF_Field::UCXF_WIDGET_TYPE_CHECKBOX constant
UCXF_Field::UCXF_WIDGET_TYPE_CONSTANT constant
UCXF_Field::UCXF_WIDGET_TYPE_PHP constant
UCXF_Field::UCXF_WIDGET_TYPE_PHP_SELECT constant
UCXF_Field::UCXF_WIDGET_TYPE_SELECT constant
UCXF_Field::UCXF_WIDGET_TYPE_TEXTFIELD constant
UCXF_Field::__get public function Getter
UCXF_Field::__set public function Setter