You are here

function _webform_edit_product in Ubercart Webform Integration 7.2

Same name and namespace in other branches
  1. 6 components/product.inc \_webform_edit_product()
  2. 7.3 components/product.inc \_webform_edit_product()

Implements _webform_edit_component(). http://api.lullabot.com/_webform_edit_component/7

File

components/product.inc, line 60
Webform module product component.

Code

function _webform_edit_product($component) {
  $form = array();

  // Disabling the description if not wanted.
  $form['description'] = array();
  $form['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Default quantity'),
    '#default_value' => $component['value'],
    '#description' => t('The default quantity of product.'),
    '#size' => 5,
    '#maxlength' => 10,
    '#weight' => 0,
    '#id' => 'email-value',
  );

  // Most options are stored in the "extra" array, which stores any settings
  // unique to a particular component type.
  $form['extra']['product'] = array(
    '#type' => 'textfield',
    '#title' => t('Product'),
    // Notice: Undefined index: product in _webform_edit_product()
    '#default_value' => $component['extra']['product'],
    '#weight' => -3,
    '#size' => 60,
    '#description' => t('Please select a product. Only products that do not contain attributes will be displayed.'),
    '#autocomplete_path' => 'uc_webform/autocomplete',
  );
  $form['display']['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#description' => t('Width of the textfield.') . ' ' . t('Leaving blank will use the default size.'),
    '#size' => 5,
    '#maxlength' => 10,
    '#weight' => 0,
    '#parents' => array(
      'extra',
      'width',
    ),
  );
  $form['display']['disabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disabled'),
    '#return_value' => 1,
    '#description' => t('Make this field non-editable. Useful for setting an unchangeable default value.'),
    '#weight' => 3,
    '#default_value' => $component['extra']['disabled'],
    '#parents' => array(
      'extra',
      'disabled',
    ),
  );
  if (isset($component['extra']['width'])) {
    $form['display']['width']['#default_value'] = $component['extra']['width'];
  }
  return $form;
}