Fill joomla's form field

i have a simple form made with joomla. I have two fields for email:

echo $this->form->getLabel('email1');
echo $this->form->getInput('email1');

echo $this->form->getLabel('email2');
echo $this->form->getInput('email2');

i'm trying to fill those fields when the user is allready logged in, but i have a issue. here is the code:

$user = JFactory::getUser();
$login = false;
if(!$user->get('guest')){
    $login = true;
    $email = $user->email;
}
...
echo '<input type="text" name="jform[email1]" class="validate-email required" id="jform_email1" value="'.$email.'" size="30" required="required" aria-required="true" disabled/><br>';
echo '<input type="hidden" name="jform[email2]" class="validate-email required" id="jform_email2" value="'.$email.'" size="30" required="required" aria-required="true" disabled/>';

In the output, the fields's type change to

<input type="email" name="jform[email1]" class="validate-email required" id="jform_email1" value="mail@mymail.com" size="30" required="required" aria-required="true" disabled="">
<input type="email" name="jform[email2]" class="validate-email required" id="jform_email2" value="mail@mymail.com" size="30" required="required" aria-required="true" disabled="">

I just want to disabled those fields and hide the second field

Thank you for your help

Answers


I found the answer, hope that will help someone:

echo $this->form->getLabel('email1');
$this->form->setValue('email1',null,$email);
$this->form->setFieldAttribute( 'email1', 'readonly', 'true' );
echo $this->form->getInput('email1');

echo $this->form->getLabel('email2', array('style' => 'display:none;'));
$this->form->setValue('email2',null,$email);
$this->form->setFieldAttribute( 'email2', 'readonly', 'true' );
echo $this->form->getInput('email2', array('type' => 'hidden'));

Need Your Help

Can I call one feature file into some another feature file present in same suite (solution for calling scenarios will also do)

c# automation bdd specflow gherkin

I have a test suite where I have multiple BDD scenarios present in different feature files like mentioned below,

fopen with unicode filename

windows winapi visual-c++

I have to use a library that accepts file names as strings (const char*). Internally files are opened with fopen. Is there a way to make this library to accept unicode file name? Can I use