This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
hi, i'm trying to render a form in a modal that has file upload form widget. when i choose a file it will be rendered on the form but as i click on that file for edit or delete it throw this error : "A widget with class name 'formFiles' has not been bound to the controller" on line 517 of /opt/lampp/htdocs/imis-lawyer/modules/backend/classes/Controller.php my createForm function is like this:
public function onCreateForm()
{
$dashboard_id = post('dashboard_id');
$level_id = post('level_id');
if($this->checkPermission($level_id)){
$dashboardModel = Dashboard::find($dashboard_id);
$config = $this->makeConfig($this->levelManager);
$config->model = new \Imis\ProcessManagement\Models\Dashboard;
$config->arrayName = 'Dashboard';
$widget = $this->makeWidget('Backend\Widgets\Form', $config);
$widget->bindToController();
$this->vars['widget'] = $widget;
$this->vars['dashboard_id'] = $dashboard_id;
$this->vars['dashboard_model'] = $dashboardModel;
return $this->makePartial('levelmanager/level_manager');
}else{
return $this->onShowPassed();
}
}
and config file for file upload is:
files: type: fileupload mode: file
any body knows what's the problem!? Thank you.
Hello from the future! I have this problem with an Image field. Somebody out there with a tip...?
if you are implementing FormBehavior then write this code in your controller constructor
$this->initForm($this->formCreateModelObject());
Or
as I can see you are writing your own form widget so now you need to bind your controller to your widget for each request made to your controller.
public function __construct()
{
// Your controller code
$this->getWidget();
}
public function onCreateForm()
{
$level_id = post('level_id');
if($this->checkPermission($level_id)){
$this->vars['widget'] = $this->getWidget();
$this->vars['dashboard_id'] = $dashboard_id;
$this->vars['dashboard_model'] = $dashboardModel;
return $this->makePartial('levelmanager/level_manager');
}else{
return $this->onShowPassed();
}
}
public function getWidget(){
$dashboard_id = post('dashboard_id');
$dashboardModel = Dashboard::find($dashboard_id);
$config = $this->makeConfig($this->levelManager);
$config->model = new \Imis\ProcessManagement\Models\Dashboard;
$config->arrayName = 'Dashboard';
$widget = $this->makeWidget('Backend\Widgets\Form', $config);
$widget->bindToController();
return $widget;
}
it will solve the problem.
1-5 of 5