dsiv4041 2014-01-28 13:16
浏览 15

填写joomla的表格字段

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

  • 写回答

1条回答 默认 最新

  • doulu1544 2014-01-28 14:11
    关注

    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'));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值