1

This is the scenario:

A webform with the following fields

Question -> Textfield
Category -> Select options (Listbox) Listing vocabulary HETCAT

A content type Question with these fields

Title
Category -> Term reference listing vocabulary HETCAT

Once the webform is submitted i create a new question node. Everything works fine, the Question field of the webform is the new Question node title, but i can not see the way to copy the category selected on the webform to the new node

Thanks in advance

This is the export rule code

{ "rules_submissions_to_node" : {
"LABEL" : "Submissions to node",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "webform_rules", "rules" ],
"ON" : { "webform_rules_submit" : [] },
"IF" : [
  { "webform_has_id" : {
      "form_id" : [ "form_id" ],
      "selected_webform" : { "value" : { "webform-client-form-140" : "webform-client-form-140" } }
    }
  }
],
"DO" : [
  { "entity_create" : {
      "USING" : {
        "type" : "node",
        "param_type" : "het_question",
        "param_title" : [ "node:title" ],
        "param_author" : [ "user" ]
      },
      "PROVIDE" : { "entity_created" : { "new_question" : "New question" } }
    }
  },
  { "data_set" : { "data" : [ "new-question:title" ], "value" : "[data:question-value]" } },
  { "data_set" : {
      "data" : [ "new-question:field-month" ],
      "value" : [ "site:current-date" ]
    }
  },
  { "entity_save" : { "data" : [ "new-question" ], "immediate" : 1 } },
  { "mail_to_users_of_role" : {
      "roles" : { "value" : { "4" : "4" } },
      "subject" : "New question to approve",
      "message" : "[new-question:title]\r\n\r\n\u003Ca href=\u0022[new-question:edit-url]\u0022\u003EEdit to publish it\u003C\/a\u003E\r\n",
      "from" : "[site:name]"
    }
  },
  { "node_unpublish" : { "node" : [ "new-question" ] } }
]}}
  • How do you achieve node_save? some code would be helpful – Pan Chrono Jul 10 '14 at 13:07
  • of course, thanks for the help. I've added the code – Ferlaiker Jul 10 '14 at 13:24
0

Well, finally i figure it out how to solve it.

I'm using Webform Rules module

Just need to add an Execute custom PHP code action and set the value like this

// $new_question is my new node.
// $data['components']['category'] is my webform listbox component.
// $new_question->field_category is my taxonomy reference field select list.

$tid = substr($data['components']['category']['value'][0],4,2);
$new_question->field_category['und'][0]['tid'] = $tid;
| improve this answer | |

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.