- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在学习如何使用 Zend Framework 2 (2.1.4) 表单并遇到此错误。
Call to a member function insert() on a non-object in ... /Zend/Form/Fieldset.php on line 178
namespace FBWeb\Form;
use Zend\Form\Form;
use Zend\Form\Element;
class ClientForm extends Form
{
public function __construct()
{
$this->setAttribute('method', 'post');
$this->add(array(
'name' => 'client',
'type' => 'Zend\Form\Element\Text',
'options' => array(
'label' => 'Client Name',
),
'attributes' => array(
'type' => 'text',
),
));
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'value' => 'Add'
),
));
}
}
namespace FBWeb\Controller;
use Zend\Debug\Debug;
use Zend\Mvc\MvcEvent;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Session\Container;
use Zend\Http\Request;
use FBWeb\Form\ClientForm;
class ClientController extends AbstractActionController
{
public function indexAction()
{
$clientform = new ClientForm();
return array('form' => $clientform);
}
}
<div id="clientformtable">
<?php
$form = $this->form;
$form->setAttribute('action','/app/client/add');
$form->prepare();
echo $this->form()->openTag($form);
$client = $form->get('client');
echo $this->formRow($client);
echo $this->form()->closeTag();
?>
</div>
最佳答案
由于表单设置不正确,会出现此错误消息以及类似的错误消息。正如您在 __construct()
上方的代码中看到的那样函数不调用父构造函数。因此内部“引导”不会发生并且会发生错误。
在处理 Zend\Form\Form
时,您必须确保始终调用父构造函数。和/或 Zend\Form\Fieldset
.
parent::__construct('client-form');
关于forms - Zend\Form : Call to a member function insert() on a non-object in Zend/Form/Fieldset. php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16022555/
嗨,我有一个包含此代码的 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
我是一名优秀的程序员,十分优秀!