You are here

function _webform_display_productfield in Commerce Webform 8

Same name and namespace in other branches
  1. 7.2 productfield.inc \_webform_display_productfield()
  2. 7 productfield.inc \_webform_display_productfield()

Implements _webform_display_component().

File

./productfield.inc, line 370

Code

function _webform_display_productfield($component, $value, $format = 'html') {
  $options = array();
  foreach ($component['extra']['items'] as $product_id => $details) {
    $options[$product_id] = "{$details['sku']}: {$details['title']} ";
  }
  return array(
    '#title' => $component['name'],
    '#weight' => $component['weight'],
    '#theme' => 'webform_display_productfield',
    '#theme_wrappers' => $format == 'html' ? array(
      'webform_element',
    ) : array(
      'webform_element_text',
    ),
    '#format' => $format,
    '#options' => $options,
    '#value' => (array) $value,
    '#translatable' => array(
      'title',
      'options',
    ),
  );
}