Fill joomla#39;s form field(填写 joomla 的表单域)
本文介绍了填写 joomla 的表单域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个用 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
感谢您的帮助
推荐答案
我找到了答案,希望对某人有所帮助:
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'));
这篇关于填写 joomla 的表单域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:填写 joomla 的表单域
基础教程推荐
猜你喜欢
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- php中的PDF导出 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- php中的foreach复选框POST 2021-01-01
- 将变量从树枝传递给 js 2022-01-01
