我有一个问题,我无法从CRUD中的表单获取值(使用$ form-> addField添加)。我只是得到模型中的内容,但没有额外的值...
MODEL:
class Model_Admin extends Model_Table {
public $table ='admin';
function init(){
parent::init();
$this->addField('name')->mandatory('Name required');
$this->addField('email')->mandatory('Email required');
$this->addField('password')->type('password')->mandatory('Password required');
}
}
在页面上我创建扩展CRUD并添加另外两个字段:
$adminCRUD = $this->add('MyCRUD');
$adminCRUD->setModel('Admin');
if($adminCRUD->isEditing('add')){
$adminCRUD->form->addField('line','test2','TEST LINE');
$adminCRUD->form->addField('DropDown', 'appfield','Manages Applications')
->setAttr('multiple')
->setModel('Application');
}
扩展CRUD:
class MyRUD extends CRUD {
function formSubmit($form)
{
//var_dump($form);
var_dump($form->get('test2'));
var_dump($form->get('appfield'));
try {
//$form->update();
$self = $this;
$this->api->addHook('pre-render', function () use ($self) {
$self->formSubmitSuccess()->execute();
});
} catch (Exception_ValidityCheck $e) {
$form->displayError($e->getField(), $e->getMessage());
}
}
}
我为$ form-> get('test2')或$ form-> get('appfield')获取null。我检查了整个$ form对象,并且没有来自test2的值。过程中的Somwhere会丢失(或下载),如何在扩展CRUD中获取它?
提前致谢!