-
Notifications
You must be signed in to change notification settings - Fork 111
UploadImg inside Modal / CRUD #1029
Copy link
Copy link
Closed
Labels
Description
I tried to customize the default modal form in a CRUD. Used a custom Form/Executor class: MyForm and MyExecutor.
class MyForm extends \atk4\ui\Form
public function init(){
parent::init();
}
function setModel($m, $fields = null) {
parent::setModel($m, false);
$this->addField('name');
$img = $this->addField('image', ['UploadImg']);
$img->onDelete(function ($files){
//code goes here
});
$img->onUpload(function ($files) {
//code goes here
});
$img->setThumbnailSrc( $m['image']);
return $this->model;
}
}
class MyExecutor extends atk4\ui\ActionExecutor\UserAction
{
public $form = HazardsForm::class;
public function init()
{
parent::init();
}
};
$crud->executor = MyExecutor::class;
$crud->setModel($m);
The modal displays correctly the custom form. But when I delete an previous uploaded picture, or try to upload a new one I get the following error:
Critical Error</div>\n atk4\ui\Exception \n onUpload and onDelete callback must be called to use file upload.
The order by witch I declare onDelete or onUpload callbacks afects the delete/upload error.
Reactions are currently unavailable