I would link to add an extra mail configuration to the existing mail config.
I'v done this in my custom module with the hook_form_alter() :
function webforms_form_alter(&$form, &$form_state, $form_id) {
if ($form_id === 'webform_email_edit_form') {
$node = $form['#node'];
// Add the checkbox to disable the email for current recipients.
$form['extra']['resend_up_del'] = array(
'#title' => t('Resend mail by submission update/delete'),
'#description' => t('Check to enable resend this mailing when a submission is updated/deleted. The subject will be prefixed by UPDATE or DELETE'),
'#type' => 'checkbox',
'#default_value' => $node->webform['emails'][$form['eid']['#value']]['extra']['resend_up_del'],
);
return $form;
}
}
I changed the function webform_email_edit_form_submit() in webform.emails.inc so this extra config will be saved within the webform node (Patch included) and can be used within the hooks when a submission is updated and deleted.
Is this the way to go ?
Could it be a feature ?
Comments
Comment #2
danchadwick commentedThis seems like a reasonable strategy.
Instead of hacking webform, install your own submit handler into the form to save the extra settings. They will be saved to the database (I think). I'm not sure what else "extra" is used for without reading the code.
No, I don't see this going into webform, especially with Drupal hooks make it reasonable to accomplish without modifying webform itself.
Comment #3
pbosmans commentedI tried that but couldn't accomplish what i wanted.
Put my settings into the webform so it will be saved into the webform_emails table.
This table have an extra field that is 'A serialized array of additional options for the e-mail configuration, including value mapping for the TO and FROM addresses for select lists.'
But with the current setup webform.emails.inc creates an empty extra array, so there is no possibility to add 'additional options' to it.
I appreciate any other suggestions to accomplish my needs.
Comment #5
dobe commented@DanChadwick
I was looking at doing the same thing. Extra is used to store the "Email components" and other things according to the column description.
The rest of webform allows you to modify the form and submit the data the way you describe through hooks (and update the extra column). The issue with the email hook is that the "$email" variable gets created and submitted to database in the same submit handler. Giving no way to modify. In addition the only way that "extra" gets into the variable is through here:
So the only way that you can really get your data in is to have a module declare a submit handler that gets fired AFTER webforms and do another write to the database. Which isn't this one of the powers of the hooks? To modify so we have less db writes/reads?
The code I am using to bypass this until the above patch of #1 gets committed is:
Notice that I am doing an additional write AND having to create a little bit of processing code just to get this in unscathed.
So please commit the above patch +1+1 it has very little effect and makes the email form work similar to the rest of webform's edit forms.
Comment #7
dobe commentedReroll
Comment #8
dobe commentedComment #9
pbosmans commented@dobe
Thx for updating the patch.
I needed it on another site, with succes.
Hopefully it will be committed.
Comment #10
chris matthews commentedThe 3 year old patch in #7 still applies cleanly to the latest 7.x-4.x-dev and would be a nice feature to have.
Comment #11
liam morlandDrupal 7 is no longer supported. If this applies to a supported version, please re-open.