0

so I've been trying to implement a 'sample request' feature on my site. I had tried to use the webform views module, which worked except that I couldn't add checkboxes to the view that displayed and webform views doesn't play well with the latest release of webform.

I found this Sample Request w Views, Flag, and Webform tutorial, which is basically exactly my use case.

I've created my own module, and am stuck with some of syntax in the view and options parsing array function. The article mentions that I need to reference the title of the nodes 'owner' but I'm not 100% on how this applies to my implementation.

I've altered the code so the function names reflect my custom module, my predefined view of my flag, but I can't get the list to show up in my predefined lists options. I think this is because I don't have the right field referencing my node's title, but I'm not sure. Also the dpm() statement didn't fire.

I know this is a lot, thanks in advance.

 function webform_hook_select_options_info() { $items = array(); if (function_exists('_MODULE_user_flag_sample_requests')) {
 $items['MODULE_user_flag_sample_requests'] = array(
  'title' => t("Sample Requests (User Flag list)"),
  'options callback' => '_MODULE_user_flag_sample_requests',
 );}return $items;} function _MODULE_user_flag_sample_requests() {$view = views_get_view('webform_flag_views', TRUE);$view->set_display('webform_options');$view->execute();$options = array();dpm($options);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_ref_node_title . ' (' . $item->node_title . ')' . '</a>';
 }}else {
 $options[0] = t("Nothing");}return $options;}
1

It is not webform_hook_select_options_info() it is webform_hook_webform_select_options_info().
(If your module name is webform_hook)
The MODULE parts are the places, where you should enter your modul name.
Inside the foreach you need to enter valid fields from your content that listed inside the view.
Be sure that the Flag Modul is working.

  • Thank you!!! As a follow up, how would I identify the field in my array? – nizz0k May 7 '15 at 22:55
  • You could use diffrent ways. I normaly go to the contenttype and look for the fieldnames inside of it. – Nugorra May 8 '15 at 6:27
  • I'm wondering about the syntax though; I've tried field_title, field_field_title, even field_ref_commerce product node title, the Dpm statements aren't really giving me any hints to the syntax either. – nizz0k May 8 '15 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.