Prepopulate name field in submitcontent form

ln lnemeth 24 Dec, 2008
Greetings.

Love the component and the submitcontent form. I had only one complaint with it, which is that I wanted registered users to be able to submit articles under their names without having to type it in -- in other words, I wanted to prepopulate the name field with the user's Joomla username. Wasn't hard, in the end, and I thought I'd share it for others.

In the form code, add a "value" attribute to the input tag, as follows:

<input value="<?php
$user =& JFactory::getUser();
 
  if ($user->guest) {
    echo "";
  } else {
     echo $user->username;
	 }
?>" class="cf_inputbox required validate-alpha" maxlength="15" size="30" id="text_7" name="created_by_alias" type="text">


Works perfectly in Joomla 1.5.8.
pe peters901 24 Dec, 2008
Hi,

How can you make this field not editable?

Regards,

Jaap
Gr GreyHead 24 Dec, 2008
Hi Jaap,

Add the readonly="readonly" attribute. Or just add the name into ordinary html.
<div>your name is <?php echo $user->name; ?>, isn't it!</div>


Bob
ne nemoz_ 07 Jan, 2009
thank you lnemeth,
it's exactly what i was looking for!!!
This topic is locked and no more replies can be posted.