vtiger Forum Index vtiger
The Honest Open Source CRM
 

how to webform custom fields?
Click here to go to the original topic

 
       vtiger Forum Index -> Web Forms
Previous topic :: Next topic  
Author Message
alkatraz
Guest





Posted: Mon Sep 26, 2005 5:33 am    Post subject: how to webform custom fields?  

How do I pass info for custom created fields (for example, the contacts script)

What are the posibilities with the webform addon?

Is there a way to use a form to auto add email(s) to a contact's record, like you can with the outlook/thunderbird plugins?

I've got intermediate skills with php but it looks like you're using soap/xml to transfer data, is that right?

Thank you
Back to top  
greggster
Guest


Joined: 27 Oct 2006
Posts: 65
Location: San Francisco

Posted: Wed Feb 07, 2007 3:13 am    Post subject: Re: how to webform custom fields?  

1. create a custom field, say "Loan Purpose" in the Leads module. In my forms, I'll call this "purpose"
2. Using phpmyadmin, browse to the Table: vtiger_leadscf
3. Look at the custom field name for the field in question - mine was called cf_453 This is the field name to be used in webforms.php
4. The name cf_453 only needs to be used in webforms.php, for the other files, call it something friendly - here I used loanpurpose.
5. assign like this:
index.php: add the field name loanpurpose to the line starting with: function create_lead_from_webform

In my implementation, used a drop down list in the form like this:

<tr><th>Loan Purpose:</th>
<td><select name="loanpurpose">
<option value="Purchase">Purchase</option>
<option value="Refi - Rate,Term">Refi - Rate,Term</option>
<option value="Refi - Cash-out">Refi - Cash-out</option>
<option value="Second">Second</option>
<option value="Other">Other</option>
</select></td>
</tr>

send_data.php: 'loanpurpose'=>"$loanpurpose"

webforms.php: Add in both places:
in if($_REQUEST['create'] == 'lead') function:
$loanpurpose = $_POST['loanpurpose'];

and in $params = array(
$focus->column_fields['cf_453'] = $loanpurpose; <-- this is where the new form value gets mapped to the custom field ID.
Back to top  
BrianLaughlin
Guest


Joined: 13 Dec 2005
Posts: 801

Posted: Wed Feb 07, 2007 8:41 am    Post subject: Re: how to webform custom fields?  

Great post. This has been added to the wiki.
Back to top  
juliettbravo
Guest


Joined: 25 Oct 2007
Posts: 1

Posted: Thu Oct 25, 2007 4:30 pm    Post subject: Re: how to webform custom fields?  

Hi!

I've been trying to add custom fields to the lead module (5.0.2) as described in the post above, but no result yet. I've edited the index.php file (the form), edited the send_data.php file but after sending the data just doesn't appear in Vtiger.

What I have done so far:
Index.php:
Code:
<tr><th>Adres:</th>
<td><input type=text name=lane size=30 value="<?php echo $_POST['lane']?>"></td>
</tr>
<tr><th>P.O. box:</th>
<td><input type=text name=pobox size=30 value="<?php echo $_POST['pobox']?>"></td>
</tr>

etc.

send_data.php:
Code:
if($_REQUEST['create'] == 'lead')
{
   $lastname = $_POST['lastname'];
   $email = $_POST['email'];
   $phone = $_POST['phone'];
   $company = $_POST['company'];
   $country = $_POST['country'];
   $description = "WebForm : ".$_POST['description'];
   $firstname = $_POST['firstname'];
   $lane = $_POST['lane'];
   $pobox = $_POST['pobox'];
   $city = $_POST['city'];
   $mobile = $_POST['mobile'];
   $fax = $_POST['fax'];

   $params = array(
            'lastname' => "$lastname",
                      'email'=>"$email",
                      'phone'=>"$phone",
                      'company'=>"$company",
                      'country'=>"$country",
                      'description'=>"$description",
                      'assigned_user_id'=>"$assigned_user_id",
                        'firstname'=>"$firstname",
                      'lane'=>"$lane",
                      'pobox'=>"$pobox",
                      'city'=>"$city",
                      'mobile'=>"$mobile",
                      'fax'=>"$fax"
         );


The only file I can't find is the webforms.php file.. Where can this be found? I am adding this webform to a website, I don't have direct access to the files of the Vtiger CRM (different server), only to the files of the webform.

Any help would be appreciated!
Kind regards,
Bart van Stratum.
Back to top  
gtron
Guest


Joined: 20 Nov 2007
Posts: 2

Posted: Tue Nov 20, 2007 1:30 am    Post subject: Re: how to webform custom fields?  

^^ that's because that example is not only sloppy but it's wrong. not sure why it was added to wiki. anyway, it was a nice effort at support. i'll attempt clearing things up for you using the same information.

1. Open 'Lead\index.php' and add the select list the same way as above:

Code:
<tr><th>Loan Purpose:</th>
<td><select name="loanpurpose">
<option value="Purchase">Purchase</option>
<option value="Refi - Rate,Term">Refi - Rate,Term</option>
<option value="Refi - Cash-out">Refi - Cash-out</option>
<option value="Second">Second</option>
<option value="Other">Other</option>
</select></td>
</tr>


2. Open 'Lead\send_data.php'
after
Code:
if($_REQUEST['create'] == 'lead')
{
   $lastname = $_POST['lastname'];
   $email = $_POST['email'];
   $phone = $_POST['phone'];
   $company = $_POST['company'];
   $country = $_POST['country'];


add:
Code:
$loanpurpose = $_POST['loanpurpose'];


after:
Code:
   $params = array(
            'lastname' => "$lastname",
            'email'=>"$email",
            'phone'=>"$phone",
            'company'=>"$company",
            'country'=>"$country",


add:
Code:
'loanpurpose'=>"$loanpurpose",


stay consistent and keep everything in order.

3. Open '/public_html/CRM/soap/webforms.php' <--- that's my path, yours might be different

Find:
Code:
function create_lead_from_webform($lastname, $email, $phone, $company, $country, $loanpurpose,  $assigned_user_id)


Replace with:
Code:
function create_lead_from_webform($lastname, $email, $phone, $company, $country, $loanpurpose, $description, $assigned_user_id)


the order in which you place '$loanpurpose' is important here so make sure it's in the same order as everything else. in this case it's been between '$country' and '$description'.

Find:
Code:
   require_once("modules/Leads/Leads.php");
   $focus = new Leads();
   $focus->column_fields['lastname'] = $lastname;
   $focus->column_fields['email'] = $email;
   $focus->column_fields['phone'] = $phone;
   $focus->column_fields['company'] = $company;
   $focus->column_fields['country'] = $country;


Add:
Code:
$focus->column_fields['cf_450'] = $loanpurpose;   


now you should be good to go. hope that cleared things up a bit. [/b]
Back to top  
 
       vtiger Forum Index -> Web Forms
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.15 © 2001, 2002 phpBB Group