CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Posting Data To a Profile form
Pages: [1]

Author Topic: Posting Data To a Profile form  (Read 4438 times)

ngoweb

  • Guest
Posting Data To a Profile form
September 18, 2009, 11:41:37 am
Hi all,
I am a newbie with Civi but loving it!
I have a Profile form set up in civi but what i am looking to do is have a hidden field on it which accepts either post or get data from the previous page.
How can i do this?
Do I use a hook or is there a simpler way that i am missing!
Thanks all for any help!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Posting Data To a Profile form
September 18, 2009, 05:09:41 pm

depends on what you want to do with these hidden fields?

can u explain your use case and what u r trying  to do

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ngoweb

  • Guest
Re: Posting Data To a Profile form
September 18, 2009, 06:06:52 pm
Hi,
Basically i have some data on another form and need to post that data to a field in the profile form in civicrm.
so there is text data which is in a field called tourdetails this i am posting to the profile form.
I have a field in there and want to populate that field with the posted date.
I tried using standalone forms but they dont seem to work.
This is the form page http://asgreenasitgets.net/index.php?option=com_civicrm&task=civicrm/profile/create&reset=1&gid=3
That form works fine.
The standalone form is here
http://asgreenasitgets.net/tourbuilder2/form.html
but that doesnt seem to work.
I hope that makes it clearer!
Thanks :D

ngoweb

  • Guest
Re: Posting Data To a Profile form
September 18, 2009, 07:34:53 pm
i may have come closer to an answer!
the standalone form sort of works.
If i visit the integrated form URL first then the standalone form works fine.
If i dont it just redirects to the index page after submission.
I am assuming this has something to do with a session variable not getting set on the standalone till you visit the actual form page.
Not actually any use cause i still cant post data to the integrated form but getting closer i think!

ngoweb

  • Guest
Re: Posting Data To a Profile form
September 27, 2009, 09:16:36 am
Any clues anyone?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Posting Data To a Profile form
September 27, 2009, 12:22:23 pm

not sure why, but for now, i would just use the direct form url. Yes, it does seem to be the session not getting set on initial form load

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ngoweb

  • Guest
Re: Posting Data To a Profile form
October 06, 2009, 01:20:54 pm
Hi Donald,
Thanks for the reply,
The issue is I really need to find a way to post some data to one of the form fields which i can't use if i use the direct link.
is their a reason this wouldn't work - surely other joomla users can use standalone forms or am i just going nuts!

This is my form set up

Tour Leaders: University/Organization Name
(Contact)   Public Pages and Listings   

First Name
(Individual)   Public Pages and Listings   

Last Name
(Individual)   Public Pages and Listings   

Email (Primary)
(Contact)   Public Pages and Listings   

Phone (Primary)
(Contact)   Public Pages and Listings   

Tour Leaders: Comments/Notes
(Contact)   Public Pages and Listings   

Tour Leaders: TourDetails
(Contact)   Public Pages and Listings   

This is the form code.*I have also upgraded to 3.0 in the hope it would work also but no luck!!
Code: [Select]
<form  action="http://www.asgreenasitgets.net/index.php?option=com_civicrm&amp;task=civicrm/profile/edit&amp;gid=3&amp;reset=1&amp;" method="post" name="Edit" id="Edit" >



  <div><input name="postURL" type="hidden" value="http://asgreenasitgets.net/index.php?option=com_content&amp;id=299" />
<input name="cancelURL" type="hidden" value="http://www.asgreenasitgets.net/index.php?option=com_civicrm&amp;task=civicrm/profile&amp;reset=1&amp;gid=3" />
<input name="group[1]" type="hidden" value="1" />
<input name="cms_create_account" type="hidden" value="1" />
<input name="_qf_default" type="hidden" value="Edit:cancel" />
</div>



<script type="text/javascript" src="http://www.asgreenasitgets.net/administrator/components/com_civicrm/civicrm/js/Common.js"></script>
<div id="crm-container" lang="en" xml:lang="en">

       
     
   <fieldset>
      <div class="messages help">
    Please enter a user name to create an account .
If you already have an account, <a href='http://www.asgreenasitgets.net/index.php?option=com_user&view=login'>please login</a> before completing this form.      </div>
      <div> </div>
      <div id="details">
<table class="form-layout-compressed">
    <tr>
       <td><label for="cms_name">  Username
   <span class="marker" title="This field is required.">*</span>
</label></td>
       <td><input name="cms_name" type="text" id="cms_name" class="form-text required" /> <a id="checkavailability" href="#" onClick="return false;"><strong>Check Availability</strong></a>
          <span id="msgbox" style="display:none"></span><br />
          <span class="description">Your preferred username; punctuation is not allowed except for periods, hyphens, and underscores.</span>
       </td>
    </tr>
   
           <tr>
          <td><label for="cms_pass">Password</label></td>
          <td><input name="cms_pass" type="password" id="cms_pass" class="form-password" /></td>
       </tr>       
       <tr>
          <td><label for="cms_confirm_pass">Confirm Password</label></td>
          <td><input name="cms_confirm_pass" type="password" id="cms_confirm_pass" class="form-password" /><br />
             <span class="description">Provide a password for the new account in both fields.           </td>
       </tr>
    </table>       
      </div>
   </fieldset>

   
   <script type="text/javascript">
   
     
   function showMessage( frm )
   {
      var cId = '';
      if ( cId ) {
alert('You are logged-in user');
frm.checked = false;
      } else {
var siteName = 'http://www.asgreenasitgets.net/administrator/';
alert('Please login if you have an account on this site with the link ' + siteName  );
      }
   }
   var lastName = null;
   cj("#checkavailability").click(function() {
      var cmsUserName = cj.trim(cj("#cms_name").val());
      if ( lastName == cmsUserName) {
/*if user checking the same user name more than one times. avoid the ajax call*/
return;
      }
      /*don't allow special character and for joomla minimum username length is two*/

      var spchar = "\<|\>|\"|\'|\%|\;|\(|\)|\&|\\\\|\/";

     
      var r = new RegExp( "["+spchar+"]", "i");
      /*regular expression \\ matches a single backslash. this becomes r = /\\/ or r = new RegExp("\\\\").*/
      if ( r.exec(cmsUserName) ) {
alert('Your username contains invalid characters');
      return;
      }
     
else if ( cmsUserName && cmsUserName.length < 2 ) {
    alert('Your username is too short');
    return;
}
     
      if (cmsUserName) {
/*take all messages in javascript variable*/
var check        = "Checking...";
var available    = "This username is currently available.";
var notavailable = "This username is taken.";
         
         //remove all the class add the messagebox classes and start fading
         cj("#msgbox").removeClass().addClass('cmsmessagebox').css({"color":"#000","backgroundColor":"#FFC","border":"1px solid #c93"}).text(check).fadeIn("slow");

      //check the username exists or not from ajax
var contactUrl = "http://www.asgreenasitgets.net/index.php?option=com_civicrm&task=civicrm/ajax/cmsuser&";

cj.post(contactUrl,{ cms_name:cj("#cms_name").val() } ,function(data) {
    if ( data.name == "no") {/*if username not avaiable*/
       cj("#msgbox").fadeTo(200,0.1,function() {
  cj(this).html(notavailable).addClass('cmsmessagebox').css({"color":"#CC0000","backgroundColor":"#F7CBCA","border":"1px solid #CC0000"}).fadeTo(900,1);
       });
    } else {
       cj("#msgbox").fadeTo(200,0.1,function() {
  cj(this).html(available).addClass('cmsmessagebox').css({"color":"#008000","backgroundColor":"#C9FFCA", "border": "1px solid #349534"}).fadeTo(900,1);
       });
    }    
}, "json");
lastName = cmsUserName;
      } else {
cj("#msgbox").removeClass().text('').css({"backgroundColor":"#FFFFFF", "border": "0px #FFFFFF"}).fadeIn("fast");
      }
   });

   </script>
   
   <div id="profilewrap3"><fieldset><legend>Tour Leader</legend><table class="form-layout-compressed"><tr id="editrow-custom_2"><td class="label"><label for="custom_2">Tour Leaders: University/Organization Name</label></td><td class="edit-value"><input name="custom_2" type="text" id="custom_2" class="form-text" /></td></tr><tr id="helprow-custom_2"><td>&nbsp;</td><td class="description">Please Enter the name of your university or organsation if any.</td></tr><tr id="editrow-first_name"><td class="label"><label for="first_name">  First Name
   <span class="marker" title="This field is required.">*</span>
</label></td><td class="edit-value"><input maxlength="64" size="30" name="first_name" type="text" id="first_name" class="form-text big required" /></td></tr><tr id="editrow-last_name"><td class="label"><label for="last_name">  Last Name
   <span class="marker" title="This field is required.">*</span>
</label></td><td class="edit-value"><input maxlength="64" size="30" name="last_name" type="text" id="last_name" class="form-text big required" /></td></tr><tr id="editrow-email-Primary"><td class="label"><label for="email-Primary">  Email (Primary)
   <span class="marker" title="This field is required.">*</span>
</label></td><td class="edit-value"><input maxlength="64" size="30" name="email-Primary" type="text" id="email-Primary" class="form-text big required" /></td></tr><tr id="editrow-phone-Primary-1"><td class="label"><label for="phone-Primary-1">  Phone (Primary)
   <span class="marker" title="This field is required.">*</span>
</label></td><td class="edit-value"><input maxlength="32" size="20" name="phone-Primary-1" type="text" id="phone-Primary-1" class="form-text medium required" /></td></tr><tr id="editrow-custom_4"><td class="label"><label for="custom_4">Tour Leaders: Comments/Notes</label></td><td class="edit-value"><textarea rows="4" cols="60" name="custom_4" id="custom_4" class="form-textarea"></textarea></td></tr><tr id="helprow-custom_4"><td>&nbsp;</td><td class="description">If you have any questions or comments please enter them here. We will contact you prior to activation of your tour leader application and discuss the various aspects of running a tour for AS Green As It Gets.</td></tr><tr id="editrow-custom_5"><td class="label"><label for="custom_5">Tour Leaders: TourDetails</label></td><td class="edit-value"><input name="custom_5" type="text" id="custom_5" class="form-text" /></td></tr></table></fieldset></div><div class="crm-submit-buttons"><input class="form-submit default" accesskey="S" name="_qf_Edit_next" value="Save" type="submit" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class="form-submit default" name="_qf_Edit_cancel" value="Cancel" type="submit" /></div>

</div>
<script type="text/javascript">
  </script>
 


<script type="text/javascript">
   
cj(document).ready(function(){
cj('#selector tr:even').addClass('odd-row ');
cj('#selector tr:odd ').addClass('even-row');
});


</script>


</form>

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Posting Data To a Profile form
October 06, 2009, 03:58:23 pm
Quote from: ngoweb on October 06, 2009, 01:20:54 pm
The issue is I really need to find a way to post some data to one of the form fields which i can't use if i use the direct link.
is their a reason this wouldn't work - surely other joomla users can use standalone forms or am i just going nuts!

not sure i understand this: "post some data to one of the form fields which i can't use if i use the direct link."

I suspect there are very few users (joomla or drupal) using standalone forms

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Posting Data To a Profile form

This forum was archived on 2017-11-26.