- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在切换表单以使用 View 脚本作为装饰器。到目前为止我看到的示例在 View 脚本中执行以下操作:
<td><label for='textEmail'>Email:</label></td>
<td><?php echo $this->element->textEmail; ?></td>
我想找到一种方法,让表单对象中的文本也显示在标签中。
class RegisterForm extends Zend_Form {
public function init () {
$this->setAction('')
->setMethod('post')
->setAttrib('id','formRegister');
$this->addElement('text', 'textEmail', array('label' => 'Email: '));
$oEmail = $this->getElement('textEmail')
->setRequired(true)
->addFilter('StringTrim')
->addValidator('EmailAddress');
$oEmail->setDecorators(array('ViewHelper', 'Errors'));
$this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/RegisterForm.phtml'))));
}
}
以上是我的表单对象的定义方式。有谁知道如何访问定义的标签值?也许采用以下格式?
<?php echo $this->element->textEmail->label; ?>
这当然行不通。 :p谢谢~
最佳答案
$this->元素->getLabel()
这是我的标准字段 View 脚本:
<div class="field<?php if($this->element->hasErrors()): ?> errors<?php endif; ?>" id="field_<?php echo $this->element->getId(); ?>">
<?php if (0 < strlen($this->element->getLabel())) : ?>
<?php echo $this->formLabel($this->element->getName(), $this->element->getLabel());?>
<?php endif; ?>
<span class="value"><?php echo $this->{$this->element->helper}(
$this->element->getName(),
$this->element->getValue(),
$this->element->getAttribs()
) ?></span>
<?php if ($this->element->hasErrors()) : ?>
<?php echo $this->formErrors($this->element->getMessages()); ?>
<?php endif; ?>
<?php if (0 < strlen($this->element->getDescription())) : ?>
<span class="hint"><?php echo $this->element->getDescription(); ?></span>
<?php endif; ?>
</div>
关于scripting - Zend Form - 从表单类中提取标签值以在 View 脚本中显示的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1398102/
嗨,我有一个包含此代码的 Zend 表单 $field = new Zend_Form_Element_Submit('submit'); $field->setAttrib('class', 'bt
我现在正在尝试使用 zend expressive 并研究如何处理数据库。我在看this ,但不清楚。我使用 composer 安装 zend-db,它提到在 dependencies.global.
我已经通过 Zend auth 创建了一个登录系统,这里是代码 // userAuthentication public function authAction(){ $reque
好的,所以我对 Zend 比较陌生。我已经创建了一个新的应用程序并开始构建基于 a guide 的身份验证系统.但是,服务器正在踢出一个内部服务器错误。 检查 PHP 错误日志后,我得到以下两个错误:
编辑:: 问题是由 Zend 路由引起的,请检查更新 我正在使用 xml 文件进行导航。 编辑::以下代码来自layout.phtml文件 $config = new Zend_Config_Xml(
我想将变量从 Controller 传递到表单。如何实现?谁能帮我解决这个问题。 谢谢。 最佳答案 只是一个活生生的例子: class Admin_Form_Product extends Admin
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我使用默认 Zend_Rest_Route 来生成 Rest 路由: 所以鉴于我只是把 resources.router.routes.rest.type = Zend_Rest_Route在 app
是否存在类似于 Zend Validator Identical 的 Zend Filter? 我应该过滤 input=='test' 的情况 $el->addFilter('Identical','
在/application 文件夹中创建了几个文件夹(例如表单和模型),然后开始向这些文件夹添加类之后,如何使这些类的代码自动完成在我的各种其他文件(例如我的文件)中可用IndexController
我正在尝试删除隐藏表单元素上的默认装饰器。默认情况下,隐藏元素显示如下: Hidden Element Label (if I had set one) 我不希望隐藏元素占用页面上的空间。我想删除所
我是框架新手,但我在安装 zend 1.x 版本等方面没有任何困难。但是ZF2真的搞不懂......任何资源告诉我使用 zend 工具创建项目,即 bin 目录中的 zf.bat 或 zf.sh,但与
我想使用装饰器将下面的 Zend_Form 格式化为表格,在第一列中放置描述并 Zend_Form_Element_Radio 的选项在第二列中和 在每一行中添加 2 个选择,您可以在稍后的 html
当您查看 在下面的标记中,您会看到有一个带有 id 地址标签的 dt 和以下 dd,我想删除这些但保留 字段集。 要添加显示组,我在其中使用了这个 $this->addDisplayGroup(arr
我已经阅读了所有关于路由和 Zend 文档的帖子,但我仍然无法解决这个问题。 我有一个包含两个模块的多语言应用程序:default 和 admin。语言选择工作正常(在 Controller rout
/* Form Elements & Other Definitions Here ... */ $this->setAction("auth") ->setMethod("post")
我正在按照官方教程在 Zend 服务器上部署示例 Zend 应用程序。无论我部署什么,我唯一可以访问的是 hello world 页面(Hello world 打招呼)。 如何访问真实应用程序? ho
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 3年前关闭。 Improve thi
在 Zend 中使用命名空间的最佳实践是什么? 如何管理存储库、服务等的命名空间? 我在 Zend 文档 here 中找到了一个通用的目录结构,但它没有描述在哪里放置存储库和其他服务! 请将其视为 M
我有问题,以下 Zend 表单会引发错误。 问题是"file"元素和使用 setElementDecorators。 class Products_AddForm extends Zend_F
我是一名优秀的程序员,十分优秀!