so I'm trying to implement a similar "sample request" feature like the one in Drupal Steve's tutorial. Drupal 7 Sample Request.
The issue I'm having is that I'm not sure how the field reference is made to the node title within my view. Right now the select list is being generated and is available to my webform, but the list appears unpopulated. I'm provided with an empty select list widget, but no actual options to select
The issue is that the view itself is of a custom commerce content type "posters," with a relationship set on flag, such that I'm not sure what the field reference is to get the title field from my view. Steven mentions reference the node's owner, but I'm not sure what that means. Here is the code from Steve's implementation modified to meet my needs. I basically want to know how to pull the title field out of the view of flagged items, just no idea where to find what the reference to that would be...
function webform_hook_webform_select_options_info() {
$items = array();
if (function_exists('webform_hook_user_flag_sample_requests')) {
$items['webform_hook_user_flag_sample_requests'] = array(
'title' => t("Sample Requests (User Flag list)"),
'options callback' => 'webform_hook_user_flag_sample_requests',
);
}
return $items;
}
function webform_hook_user_flag_sample_requests() {
$view = views_get_view('webform_flag_views', TRUE);
$view->set_display('webform_options');
$view->execute();
// dpm($view);
$options = array();
if ($view->result) {
$row_class = $view->style_options['row_class'];
$attributes = $row_class ? " class='$row_class'" : '';
foreach($view->result as $item) {
$options[$item->nid] = '<a' . $attributes . '>' . render($item->field_field_img[0]['rendered']) . ' ' . $item->field_title . ' (' . $item->node_title . ')' . '</a>';
}
dpm($item);
}
else {
$options[0] = t("Nothing");
}
dpm($options);
return $options;
}
Here is the result of my dpm statement on the $item variable
(Object) stdClass
commerce_product_title (String, 9 characters ) The Rapid
product_id (String, 3 characters ) 354
field_data_field_image_commerce_product_entity_type (String, 16 characters ) commerce_product
_field_data (Array, 1 element)
field_field_image (Array, 1 element)
field_field_img (Array, 1 element)
I've tried most of the obvious options, but I've been hitting a brick wall.
The DPM of the $options variable only returns the a tag
... (Array, 1 element)
(String, 11 characters ) <a> ()</a>
Again, many thanks in advance.
hook_webform_select_options_info()
implementation? Are you sure$view->result
is not false? It's probably more helpful todpm($options)
instead of$items
. What are you returning fromwebform_hook_user_flag_sample_requests()
?