我正在使用KJSencha模塊來使Zend Framework 2與ExtJS一起工作。 模塊根據文檔進行了配置。所有其他的事情都很好。KJSencha Formhandler註解不起作用
我的應用程序必須有模塊 - 應用程序和後端。應用程序是空的,但具有定義的layout.phtml。後端模塊具有index.phtml和IndexController,空indexAction()。
後端\直接\模型中有三種模型:對象,單個和集合。他們用於直接。
後端\設置\ 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',
),
),
)
我要讓對象 - > 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();
}
// .....
}
應用\視圖\佈局\ layout.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}]}});