Forums

Form Autopopulation

olaeblue 16 Jul, 2011
Hi

I have a form which I would like to autopoulate the name & email fields for users who are logged in, but allow them to change if the wish (ie basically make user details the default text). The basic code for the boxes is below & I'm sure I can get the values from the user info but just don't know how. Any help very gratefully received. πŸ˜€

<div class="ccms_form_element cfdiv_text" id="name_container_div"><label>Name</label><input maxlength="150" size="30" class=" validate['required','alpha']" title="" type="text" value="" name="From" />
<div class="small-message">Required</div><div class="clear"></div><div id="error-message-From"></div></div><div class="ccms_form_element cfdiv_text" id="email_address_container_div"><label>Email Address</label><input maxlength="150" size="30" class=" validate['required','email']" title="" type="text" value="" name="email" />
GreyHead 16 Jul, 2011
Hi olaeblue,

Here is one way:
<?php
$user =& JFactory::getUser();
?>
<div class="ccms_form_element cfdiv_text" id="name_container_div">
  <label>Name</label>
  <input maxlength="150" size="30" class=" validate['required','alpha']" title="" 
    type="text" value="<?php echo $user->name; ?>" name="From" />
  <div class="small-message">Required</div>
  <div class="clear"></div>
  <div id="error-message-From"></div>
</div>
<div class="ccms_form_element cfdiv_text" id="email_address_container_div">
  <label>Email Address</label>
  <input maxlength="150" size="30" class=" validate['required','email']" title="" 
    type="text" value="<?php echo $user->email; ?>" name="email" />
  <div class="small-message"></div>
  <div class="clear"></div>
  <div id="error-message-email"></div>
</div>

Bob
olaeblue 16 Jul, 2011
Thanks Bob. But I'm getting the following error

Parse error: syntax error, unexpected ';' in /homepages/11/d369608199/htdocs/yrcweb/administrator/components/com_chronoforms/form_actions/show_html/cfaction_show_html.php(109) : eval()'d code on line 7

I have tried removing the ; in

type="text" value="<?php echo $user->name>; ?>"

But it still throws the same error text???? :o


<?php
$user =& JFactory::getUser();
?>
<div class="ccms_form_element cfdiv_text" id="name_container_div">
  <label>Name</label>
  <input maxlength="150" size="30" class=" validate['required','alpha']" title=""
    type="text" value="<?php echo $user->name>; ?>" name="From" />
  <div class="small-message">Required</div>
  <div class="clear"></div>
  <div id="error-message-From"></div>
</div>
<div class="ccms_form_element cfdiv_text" id="email_address_container_div">
  <label>Email Address</label>
  <input maxlength="150" size="30" class=" validate['required','email']" title=""
    type="text" value="<?php echo $user->email>; ?>" name="email" />
  <div class="small-message">Required</div>
  <div class="clear"></div>
  <div id="error-message-email"></div>
</div>
<div class="ccms_form_element cfdiv_text" id="i_will_be_accompanied_by_container_div"><label>I will be accompanied by</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="accompanied" />
<div class="small-message">Optional, list names</div><div class="clear"></div><div id="error-message-accompanied"></div></div><div class="ccms_form_element cfdiv_custom" id="meal_requirements_container_div"><label for="input_id_7">Meal Requirements</label><p>Please note that each person attending will need to complete this.  If you want to book for multiple people please complete for each person.</p><div class="clear"></div><div id="error-message-input_custom_7"></div></div><div class="ccms_form_element cfdiv_select" id="i_would_like_a_light_meal_on_friday_evening_container_div"><label>I would like a 'light meal' on Friday evening</label><select size="1" class=" validate['required']" title="" type="select" name="Fri_Eve">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
<div class="small-message">Required</div><div class="clear"></div><div id="error-message-Fri_Eve"></div></div><div class="ccms_form_element cfdiv_select" id="for_saturday_breakfast_i_would_like__container_div"><label>For Saturday Breakfast I would like:</label><select size="1" class=" validate['required']" title="" type="select" name="Sat_BFast">
<option value="Continental">Continental</option>
<option value="Full English">Full English</option>
<option value="Nothing">Nothing</option>
</select>
<div class="small-message">Required</div><div class="clear"></div><div id="error-message-Sat_BFast"></div></div><div class="ccms_form_element cfdiv_select" id="i_would_like_dinner_on_saturday_container_div"><label>I would like Dinner on Saturday</label><select size="1" class=" validate['required']" title="" type="select" name="Sat_Dinner">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
<div class="small-message">Required</div><div class="clear"></div><div id="error-message-Sat_Dinner"></div></div><div class="ccms_form_element cfdiv_select" id="for_sunday_breakfast_i_would_like_container_div"><label>For Sunday Breakfast I would like</label><select size="1" class=" validate['required']" title="" type="select" name="Sun_BFast">
<option value="Continental">Continental</option>
<option value="Full English">Full English</option>
<option value="Nothing">Nothing</option>
</select>
<div class="small-message">Required</div><div class="clear"></div><div id="error-message-Sun_BFast"></div></div><div class="ccms_form_element cfdiv_textarea" id="any_special_requirements_or_additional_notes_container_div"><label>Any special requirements or additional notes</label><textarea cols="45" rows="12" class="" title="" type="textarea" name="Special"></textarea>
<div class="clear"></div><div id="error-message-Special"></div></div><div class="ccms_form_element cfdiv_text" id="enter_the_code_container_div"><label>Enter the code</label><input maxlength="5" size="5" class="chrono_captcha_input" title="" type="text" value="" name="chrono_verification" />
{chronocaptcha_img}<div class="clear"></div><div id="error-message-chrono_verification"></div></div><div class="ccms_form_element cfdiv_submit" id="input_submit_14_container_div"><input name="input_submit_14" class="" value="Submit" type="submit" />
<div class="clear"></div><div id="error-message-input_submit_14"></div></div>
GreyHead 16 Jul, 2011
Hi olaeblue,

Apologies I made a typo

Please try value="<?php echo $user->name; ?>" without the > after name

I'll go back and correct my original post

Bob
olaeblue 16 Jul, 2011
Thank you. Works perfectly.πŸ˜€
GreyHead 16 Jul, 2011
Hi olaeblue,

It's the height setting in your template.css file here
input,
select
{
    width: 235px;
    height: 19px; // this line
    margin: 1px 0px 3px 0px;
    padding: 2px 2px 2px 2px;
    font-size: 11px;
    color: #3F3C38;
    border: 1px;
    border-color: #DDD;
    border-style: solid;
}

Bob
olaeblue 17 Jul, 2011
Hi Bob,
I Have tried changing it to 90px but nothing changes?
Also if the CSS is "input, select" then surely that CSS would affect both the select box & the input boxes above which are the correct size?

I have also tried changing the input css info below (see code where I set it to 90px) but that also does nothing.

I am doing the changes in the specific template I am using /templates/as002022/css/template.css

All the changes I have done via FTP.

I must be doing something obvious wrong but can't, for the life of me see what.

input,
select
{
	width: 235px;
	height: 25px;
	margin: 1px 0px 3px 0px;
	padding: 2px 2px 2px 2px;
	font-size: 11px;
	color: #3F3C38;
	border: 1px;
	border-color: #DDD;
	border-style: solid;
}

input
{
	height: 90px;	
}
olaeblue 17 Jul, 2011
OK ignore my last, sorted it. I was editing the wrong template.css file😢

Thank you very much
This topic is locked and no more replies can be posted.