help with extending the Form block

Permalink
I'm trying to extend the Form block to enable the user to choose an email recipient.

It is partway there; the problem is that it doesn't actually send an email to the selected user. Secondly, I can't figure out how to limit the users to a group.

If anyone would be willing to help, I'd be most grateful. Here is the code that has been added:

case 'contactlist': 
               $val=($_REQUEST['Question'.$msqID])?$_REQUEST['Question'.$msqID]:'';
               Loader::model('user_list');
               $ul = new UserList();
               if (intval($questionData['contactGroup']) != 0) {
                  $group = Group::getByID(intval($questionData['contactGroup']));
                  $ul->filterByGroup($group->gName);
               }
               $uiList = $ul->get();
               if (intval($questionData['contactAttribute']) > 0) {
                  $uak = new UserAttributeKey();
                  $uak = $uak->get($questionData['contactAttribute']);
               }
               $html = '<select name="Question'.$msqID.'" style="width:95%">';
               foreach ($uiList as $uiTmp) {


I've also attached the revised block in case that would be helpful.

Thanks!

1 Attachment

nliv
 
loving replied on at Permalink Reply 2 Attachments
I just did something like this. It is a bit cobbled together, but it works.

First, I edited the controller.php for the built-in form block to do two things:

Find the email address and send a user email at the same time it sends the administrator email. See my edits listed under comments 5/18/10 in the controller.php (attached).


Second, I created block_form_submission_user.php as a template for the email form I wanted to send the user. In my case, it is an auto-confirmation email to users who registered to exhibit at a show. Attached, also.

Third, I uploaded these to files to their proper places, so not to override any of the C5 core. My modified controller file goes in root/blocks/forms. My email template goes in root/mail.

Lastly, I went to the dashboard and refreshed the form block, and ... voila!

It would be great if someone (maybe me) I wrote a proper update, so one could indicate the email field without the cheesy little hack I have: look for the field with an @ symbol.

Hope that helps!