• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: [solved] FormBuilder 0.7 - Change the destination email
PostPosted: Thu Jun 02, 2011 5:41 pm 
Hi everybody!

I use cmsms 1.9.4.2 "Faanui", with FrontEndUsers 1.12.16, CompanyDirectory 1.8.3 and FormBuilder 0.7.

In my Company Directory Detail Template, I added this line to display the contact form and change the destination value :

Code:
{FormBuilder form='contact' value_fld29=$entry->contact_email}


Sadly isn't working!

Then I tried to change the type of the FromBuilder's field from "Email Results to set Address(es)" to a "Email results based on frontend fields" and add an hidden field where I could put the value of the email.

Same thing, it's not working, and I got this error:

Fatal error: Call to a member function GetHumanReadableValue() on a non-object in modules/FormBuilder/classes/DispositionEmailBasedFrontendFields.class.php on line 56

Using a "Email to User-Supplied Email Address" field type and changing it's value, it's the only way to make it work, but the email can be changed by users!

The reason I need that, is for every Company, I must display the same form but with a different destination.

Thanks, and sorry for my English.


Last edited by eoto88 on Fri Jun 03, 2011 6:48 pm, edited 3 times in total.

Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FormBuilder 0.7 - How to change the destination email  Topic is solved
PostPosted: Fri Jun 03, 2011 3:25 pm 
Hi everybody!

I found a solution to change the email destination.

I added this line in my CompanyDirectory Details Template :
Code:
{FormBuilder form='contact' value_fld29=$entry->contact_email}


Secondly, I added this UDT (User Defined Tag) :
Code:
$gCms = cmsms();
$form_id = $params['form_id '];

if($form_id = 1) {
  $mail =& $gCms->modules['CMSMailer']['object'];

  if(!empty($params['fld_29'])) {
    $ed = $params['fld_29'];
  } else {
    $ed= '';
  }
  if(!empty($params['your_name'])) {
    $n = $params['your_name'];
  } else {
    $n = '';
  }
  if(!empty($params['your_email_address'])) {
    $e = $params['your_email_address'];
  } else {
    $e = '';
  }
  if(!empty($params['comment'])) {
    $c = $params['comment'];
  } else {
    $c = '';
  }

  $subject = 'Test';
  $body = '<p>Name: ' . $n . '</p><p>Comment: ' . $c . '</p><p>Email: ' . $e . '</p>';
  $mail->AddAddress(  $ed );
  $mail->IsHTML( true );
  $mail->SetBody( $body );
  $mail->SetSubject( $subject );
  $mail->Send();
  $mail->reset();
}


In my form I changed the "Email Results to set Address(es)" for a "Call A User Defined Tag With the Form Results" field where I call the previous UDT.

P.S. The name of the fields could be different! If you have a better solution, I'd like to read it!


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FormBuilder 0.7 - How to change the destination email
PostPosted: Fri Jun 03, 2011 3:49 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 7999
Location: Fernie British Columbia, Canada
Quote:
$mail =& $gCms->modules['CMSMailer']['object'];


Just a tip:
the $gCms->modules array (among other things) is gone in CMSMS 1.10, so never ever use it, or any other members of the $gCms object directly. Use the accessors that are provided.

i.e: $mail = cms_utils::get_module('CMSMailer');

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FormBuilder 0.7 - How to change the destination email
PostPosted: Fri Jun 03, 2011 4:09 pm 
Oh great! Thanks!

Should I change these lines from :
Code:
$comp_dir = $gCms->GetModuleInstance('CompanyDirectory');
$feu = $gCms->GetModuleInstance('FrontEndUsers');


to :
Code:
$comp_dir = cms_utils::get_module('CompanyDirectory');
$feu = cms_utils::get_module('FrontEndUsers');


Because GetModuleInstance use the $gCms object directly!

Thanks again!


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: FormBuilder 0.7 - How to change the destination email
PostPosted: Fri Jun 03, 2011 4:18 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 7999
Location: Fernie British Columbia, Canada
I would...

In 1.10 that function in the CmsObject class is deprecated and is just a wrapper around an equivalent function in ModuleOperations.

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: [solved] FormBuilder 0.7 - Change the destination email
PostPosted: Mon Oct 15, 2012 2:03 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Fri Nov 30, 2007 9:15 am
Posts: 349
Please take a look at this article: http://www.i-do-this.com/blog/88/FormBu ... a-variable
I based it on this thread and added a little extra... :)

Greetings,
Manuel

_________________
Do you like your open source cms? Buy from the CMSMS partners || Donate
(or at least share some knowledge :D >> See some of my stuff )


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: [solved] FormBuilder 0.7 - Change the destination email
PostPosted: Sun Feb 17, 2013 4:23 pm 
Offline
Forum Members
Forum Members

Joined: Sun Jan 23, 2011 1:55 am
Posts: 20
    Hi Manuel,
    I have been trying to use the method you describe in your article and have run into a problem with the second and third lines in your code:
    Quote:
    $form_id = $params['form_id'];
    if($form_id = 4) {

    The variable $form_id is not being properly set with the above, and I had to resort to the following to get it:
    Code:
       $actparams = $smarty->get_template_vars('actionparams');
       $form_id = $actparams['form_id'];

    I believe that I must be missing something fundamental here. Surely there is an easier way to get the smarty variable form_id.

    Also, I believe the if statement should be
    Code:
        if($form_id == 4) {

    I posted a question similar to this earlier in this forum but have received no response. I would greatly appreciate any advice on getting form_id into the UDT.

    RHF


    Top
      Profile  
     
    Share On:
    Share on Facebook Share on Twitter Share on Google+
     Post subject: Re: [solved] FormBuilder 0.7 - Change the destination email
    PostPosted: Mon Feb 18, 2013 1:09 pm 
    Offline
    Dev Team Member
    Dev Team Member
    User avatar

    Joined: Fri Nov 30, 2007 9:15 am
    Posts: 349
    Dear Robert,

    Code:
    if($form_id == 4) {

    Thanks for noticing, i have changed the article accordingly!

    About the form_id:
    EDIT: I tested this and i do get the correct ID in the UDT... Oops, i tested this before correcting "$form_id == 4"...

    For the "*Call A User Defined Tag With the Form Results", did you activate the checkbox for "Export form reference to UDT as $params['FORM']? (do not do this if you are going to print_r($params) ):"?

    This should be unchecked...

    Greetings,
    Manuel

    _________________
    Do you like your open source cms? Buy from the CMSMS partners || Donate
    (or at least share some knowledge :D >> See some of my stuff )


    Top
      Profile  
     
    Share On:
    Share on Facebook Share on Twitter Share on Google+
     Post subject: Re: [solved] FormBuilder 0.7 - Change the destination email
    PostPosted: Mon Feb 18, 2013 2:30 pm 
    Offline
    Forum Members
    Forum Members

    Joined: Sun Jan 23, 2011 1:55 am
    Posts: 20
    Thanks Manuel,
    I really appreciate your response. Unfortunately, even when I uncheck the box, I still do not get the form_id using $params['form_id']. If I do a var_dump($params), I get the form variables but not the smarty variables. A great puzzle.
    Bob


    Top
      Profile  
     
    Share On:
    Share on Facebook Share on Twitter Share on Google+
     Post subject: Re: [solved] FormBuilder 0.7 - Change the destination email
    PostPosted: Tue Feb 19, 2013 1:10 am 
    Offline
    Dev Team Member
    Dev Team Member
    User avatar

    Joined: Fri Nov 30, 2007 9:15 am
    Posts: 349
    Dear Bob,

    I looked again and it appears i have been too quick telling you it worked!
    Because i tested the $form_id output before correcting the "if ($form_id = 4)", the $form_id got set to 4 inside the UDT!

    Your solution seems to work fine so i'll update the article accordingly until someone enlightens us about a better way to grab the ID...
    RHF wrote:
    $actparams = $smarty->get_template_vars('actionparams');
    $form_id = $actparams['form_id'];

    Greetings,
    Manuel

    _________________
    Do you like your open source cms? Buy from the CMSMS partners || Donate
    (or at least share some knowledge :D >> See some of my stuff )


    Top
      Profile  
     
    Share On:
    Share on Facebook Share on Twitter Share on Google+
    Display posts from previous:  Sort by  
    Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

    All times are UTC


    Who is online

    Users browsing this forum: No registered users


    You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum

    Search for:
    Jump to:  
    Hosting Nation - Managed CMSMS Hosting