Extended CRUD, function formSubmit don't get a

2019-08-30 22:58发布

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!

标签: crud atk4
0条回答
登录 后发表回答