Currently working with the Commerce module in Drupal 7.
I've hooked the product creation form (using hook_form_alter()
) to include a custom validation function. I have an image for each product that is generated on the fly and needs to be associated with the relevant product. The name of the image field is 'field_pchem_structure_image.'
I'm able to create and save the image, but I need to make sure it is added to the product when the product is saved. I've tried setting:
$form_state['values']['field_pchem_structure_image'] = $file;
However, this does not seem to work. Could someone please explain how to do this?