Reputation: 1
I am VERY new to Drupal (Drupal 7).
I am stuck at webform alteration step.
So, I have created a content type - News.
The News content type has a node reference field for referencing a webform.
Created a view (for various reasons) to list the news items.
Now, when the news item details page is displayed, I want to update a couple of webform fields. For example, the webform subject's field needs to be pre-populated with the News item title.
I understand that there is hook_form_alter
hook to update the webform, but I can't use that hook as I won't have access to the other News content type fields.
I tried template_preprocess_node
hook, but looks like that is called after the webform has been rendered as the field values were not updated.
Any help would be much appreciated.
Upvotes: 0
Views: 1888
Reputation: 352
I know this is an old post, but for anyone searching for answers.
menu_get_object()
, however you don't need to reload the node via node_load
as menu_get_object()
will give you the full node object.form_id
you can then use hook_form_alter
or hook_form_<formid>_alter()
to alter the contents of the form.More info can be found here: https://www.drupal.org/node/1558246
Upvotes: 1
Reputation: 545
Is the item detail page a node page if so you can use menu_get_object(); to get the nid then use node_load to get the data you require and then hook_form_alter to insert it into the webform.
If it is not a node page you can use devel or hook_page_alter to look for a reference to the node in the page and then use this to load the data from the node and insert into your form.
Upvotes: 0