function commerce_webform_conditional_product_select in Commerce Webform 8
Same name and namespace in other branches
- 7.2 productfield.inc \commerce_webform_conditional_product_select()
Webform conditional form callback.
1 string reference to 'commerce_webform_conditional_product_select'
- _commerce_webform_conditional_operator_info in ./
productfield.inc - Define conditional operators for productfields.
File
- ./
productfield.inc, line 827
Code
function commerce_webform_conditional_product_select($node) {
$forms = array();
webform_component_include('productfield');
foreach ($node->webform['components'] as $cid => $component) {
if (webform_component_property($component['type'], 'conditional_type') == 'productfield') {
$options = array();
$product_ids = _webform_productfield_product_ids($component);
$products = commerce_product_load_multiple($product_ids);
foreach ($products as $id => $product) {
$options[$product->product_id] = $product->title;
}
$element = array(
'#type' => 'select',
'#multiple' => FALSE,
'#size' => NULL,
'#attributes' => array(),
'#id' => NULL,
'#name' => NULL,
'#options' => $options,
'#parents' => array(),
);
$forms[$cid] = drupal_render($element);
}
}
return $forms;
}