Forums

Self populating name field

MJudge 04 Jan, 2011
I’m new to Joomla and have had fun learning it along with Chronoforms. I’ve built a simple user input form with the form wizard and it works perfectly! I would really like to dazzle the users by having the “name” field self populate since all who use the form are registered at the website. I saw a forum post with Joomla 1.5 code that does this and have been trying to adapt it to my simple little form, but apparently I have a long way to go toward learning manual coding. I can get the example form code to work on my website, (but not a combination of the two forms).

[attachment=0]MileageReportv2.txt[/attachment]

First is the code snippet I've been trying to adapt followed by the code of my original form - Can anyone help me combine the two into a working form? Thanks in advance.
GreyHead 05 Jan, 2011
Hi Mjudge,

Replace this
<?php
$user =& JFactory::getUser();
?>
<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Member Name</label>
    <input class="cf_inputbox required" maxlength="80" size="30" title="Enter User Name!" id="text_1" name="text_1" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>
with this
<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Member Name</label>
    <input class="cf_inputbox required" maxlength="80" size="30" title="Enter User Name!" id="text_1" name="text_1" type="text" value="<?php echo $user->name; ?>" />
  
  </div>
  <div class="cfclear"> </div>
</div>

Bob
MJudge 06 Jan, 2011
Thanks for your feed-back. I had a little trouble getting the hybrid form to work, but when I replaced your database reference line with the one from that original forum post it worked great. I needed that guidance on where to place code modifications and the html syntax, etc. Thanks again to both of you!
<div class="form_item">
  <div class="form_element cf_heading">
    <h2 class="cf_text">Mileage Report Form</h2>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Member Name</label>
    <input class="cf_inputbox required" maxlength="80" size="15" title="Enter User Name!" id="text_1" name="text_1" 

type="text" value="<?php $user = &JFactory::getUser();echo $user->name;?>" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Year-To-Date Total Mileage to Report</label>
    <input class="cf_inputbox required validate-number" maxlength="30" size="15" title="Enter Numbers!" id="text_2" 

name="text_2" type="text" />
  <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" 

src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Enter Mileage for the Year :: Numbers Only Please!</div>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" style="width: 150px;">Send Private Message to Prez? (Optional)</label>
    <textarea class="cf_inputbox" rows="3" id="text_3" title="" cols="34" name="text_3"></textarea>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" 

src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Private Message to Prez? :: Optional</div>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit Your Entry" name="button_4" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>
MJudge 06 Jan, 2011
P.S.
Also, how do you insert code into the forum post in that snazzy code text box?
GreyHead 06 Jan, 2011
Hi Mjudge,

Click the 'Code' button above the message edit window. Or add [.code]code here[./code] without the .s

Bob
MJudge 07 Jan, 2011
Thanks again!
This topic is locked and no more replies can be posted.