我正在使用 Zend Framework 2 的 KJSencha 模块与 ExtJS 一起工作。模块是根据文档配置的。所有其他事情都很好。
我的应用程序必须模块 - 应用程序和后端。应用程序为空,但定义了 layout.phtml。后端模块有 index.phtml 和 IndexController,indexAction() 为空。
Backend\Direct\Model 中共有三种模型:Object、Single 和 Collection。它们用于直接。
后端\config\module.config.php
'kjsencha' => array(
'direct' => array(
'services' => array(
'Direct.Tree' => 'Backend\Direct\Model\Tree',
'Direct.Single' => 'Backend\Direct\Model\Object',
'Direct.Collection' => 'Backend\Direct\Model\Collection',
),
),
)
我想让 Object->update() 成为表单处理程序。
我花了几个小时寻找原因,但 apiBuilder 仍然没有将 'formHandler: true' 附加到我的方法中。
除了这个还有什么可以做的吗?
namespace Backend\Direct\Model;
class Object extends \Backend\Direct\Entity
{
// .....
/**
* @\KJSencha\Annotation\Formhandler
*
*/
public function update($entity, $id)
{
// TODO: Implement update() method.
return array();
}
// .....
}
应用程序\视图\布局\布局.phtml
<?php
echo $this->doctype(); ?>
<html lang="en">
<head>
<meta charset="utf-8">
<?php echo $this->headTitle('PROM-PC v.2') ?>
<?php
echo $this->headLink();
echo $this->headScript();
?>
</head>
<body>
<?php
echo $this->content;
echo $this->inlineScript();
?>
</body>
</html>
后端\视图\后端\索引\index.phtml
<?php
$this->extJs()->loadLibrary();
// load custom variables set in configuration
$this->kjSenchaVariables();
// add loader configuration, which tells where ExtJs classes have to be loaded from
$this->kjSenchaLoaderConfig();
// preloads modules required to get the app running
$this->kjSenchaDirectApi();
// loads your actual application script (usually at the end of your body tag)
$this->inlineScript()->appendFile($this->basepath() . '/backend/js/app.js');
这是结果:
Ext.direct.Manager.addProvider({"type":"kjsenchamoduleremoting","url":"\/kjsencha\/rpc\/","actions":{"Direct.Tree":[{"name":"read","len":2},{"name":"update","len":2},{"name":"create","len":2},{"name":"destroy","len":2}],"Direct.Single":[{"name":"read","len":2},{"name":"create","len":2},{"name":"update","len":2},{"name":"destroy","len":2}],"Direct.Collection":[{"name":"read","len":2},{"name":"create","len":2},{"name":"update","len":2},{"name":"destroy","len":2}],"KJSencha.echo":[{"name":"__construct","len":1},{"name":"greet","len":1}]}});