Extended CRUD, function formSubmit don't get all form elements?

血红的双手。 提交于 2019-12-12 02:42:50

问题


i have a problem, i cannot get values (added with $form->addField) from form in CRUD. I just get what's in the model, but there just isn't extra values...

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');
    }
} 

On page i create extended CRUD and add two more fields:

$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');
}

Extended 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());
        }
    }
}

I get null for $form->get('test2') or $form->get('appfield'). I checked whole $form object and there isn't values from test2.. Somwhere in the process gets lost (or droped), how to get it in extended CRUD?

Thanks in advance!

来源:https://stackoverflow.com/questions/21066214/extended-crud-function-formsubmit-dont-get-all-form-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!