0

I have a field on an Organic Group and I want to transfer the field to a piece of content related to the group and have it stored in the database rather than being referenced. I've been able to do that with the Field Reference module, and the referenced field shows up when the view is rendered on the content node; however, I can't seem to pull that field into a "schedule evaluation date" in Rules Scheduler because I think it is not a hard-coded value.

So, is there any module that just takes a field from one entity/node and stores it in another entity/node when you save a new piece of content?

Or would the Computed Field module let me do this? I know I don't see a "date" type to store in the database there.

Thanks in advance!

0

I actually just ended up doing a hook_form_alter and adding a submit handler that saved the referenced field value from the form state into the field that I wanted to save it in on the non referenced node.

This worked nicely, but you had to save the node before it updates and you have to make sure to tell the web admins that the date field won't update until after they save the node. This provided a little confusion at the beginning.

So, this is a great solution for any node where you want to save form state data from one node/entity to another and have a unique identifier like nid/gid to do database lookup and save. Code sample below. I realize that node_load might be expensive to do, but since it's only happens when an admin user saves a form, I thought it was alright.

/**
 * Implements hook_form_alter().
 */
function custom_add_survey_date_form_webform_node_form_alter(&$form, &$form_state, $form_id) {

  //Add submit handler to grab and change date values
  $form['#submit'][] = 'custom_add_survey_date_submit_handler';
}

 /**
 * Adds a submit handler to webform_node_form
 */
function custom_add_survey_date_submit_handler($form, &$form_state) {

  //grab reference to event date
  $og_reference = $form_state['values']['og_group_ref']['und'][0]['target_id'];

  //load date from event plan node
  $og_node = node_load($og_reference);
  $event_date = $og_node->field_date_of_event['und'][0]['value'];

  //Store date on survey node
  $form_state['values']['field_date_of_event02']['und'][0]['value'] = $event_date;  
}

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.