2

I've attached an entityform object to content type on my site, the content is an organic group with users and administrators.

I want to extend the current emailing functionality of entityform -which currently emails an administrator, and the user who submitted it- to include the administrators for the organic group which this instance of the entityform is attached to.

As far as I can tell, when an entityform is submitted, it doesn't track which node it is connected to, it simply throws all the results for that type of form into a big pool, so I was struggling to try to create a rule that would get all the users from that organic group.

My alternative solution was to simply use hook_form_FORM_ID_alter, and add an additional submit handler to the form, and then write the email script out from there, it was mostly a last resort but that's where I'm upto.

However, this is where I'm stuck, for whatever reason, it just does not respond to my submit callback.

function mymodule_form_review_entityform_edit_form_alter(&$form, &$form_state) {

  $form['#submit'] = array(
    'entityform_edit_form_submit', 
    'mymodule_notifty_review',
  );

}

I would so hope that I'm just being an idiot and getting the syntax or the code wrong to define my own submit handler, but when I dpm out the $form, it does acknowledge that there are 2 callbacks in the array. Is this a correct way to amend the callbacks for the form submit?

(Before anyone suggests Webform, I've already been down that route, and in terms of things this form needed to have, Webform couldn't do everything EntityForm can)

4

I managed to figure out that this is how you have to put an additional callback into the entityform submit function, hopefully this will help someone out in the future

$form['actions']['submit']['#submit'] = array(
  'entityform_edit_form_submit', 
  'mymodule_notifty_review',
);
  • 1
    Thanks! Isn't $form['actions']['submit']['#submit'][] = 'entityform_edit_form_submit' a more friendly and safer way to add a callback though? – Isaac Feb 20 '14 at 11:59
  • I see what you mean about it being safer as you aren't redeclaring the array, instead you are adding to it. It's been a while since I overcame this problem but I get the feeling that your solution was what I originally tried, but I could only get it to work doing my method, which sounds like it couldn't be true, but something in the back of my mind is telling me I had to do it this way. – Andrew Morris Mar 3 '14 at 8:58
1

I am currently using entityforms for my projects as well for an HR company.

Have you tried to create view from your entity form and then use relations and contextual filters in that view to relate content. Later on using rules you can send emails containing your views/content. This way you can sideline entityforms' mailing method.

  • I've already got my submission form being pulled into a view, its already being done through a rather complex method to do so to begin with, plus I don't think I could specify the exact admin users I needed within the og group to email who I needed, but I like that idea, I might have to try using that in the future, you can have an upvote for it :) – Andrew Morris Sep 17 '13 at 8:23

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.