Dropzone in form operation? How? #730
-
Hello everyone! I am creating a ticketing subsystem into our CRM and I want to create a form operation that would basically let the user quickly edit a ticket event. I created a form operation which has 2 fields. A text and a dropzone. The controller is built like The operation defines the form in the getQuickEditForm function: public function getQuickEditForm(?int $id = null)
{
$this->crud->hasAccessOrFail('quickEdit');
$event = TicketEvents::findOrFail($id);
$this->crud->field("result")->type("wysiwyg")->default($event->result);
$this->crud->field("attachments")
->type("dropzone")
->default($event->attachments)
->withFiles([
"path" => "tickets/" . date("Y/m"),
]);
return $this->formView($id);
} This shows the field correctly. When I try to upload a file it just shows "[Object object]" under the field and the network console shows that an error is sent back from the upload handler "dropzone/upload" with the message of Looking at the stacktrace it shows that the error is thrown at My question:
Thanks for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @kde99, thanks for your question. I'm afraid the In your case, as you want to set some defaults from the main entity, the first option is suitable for you where you define a public function setupQuickEditOperation()
{
$event = $this->crud->getCurrentEntry();
$this->crud->field("result")
->type("wysiwyg")
->default($event->result);
$this->crud->field("attachments")
->type("dropzone")
->default($event->attachments)
->withFiles([
"path" => "tickets/" . date("Y/m"),
]);
} Hope this resolves the issue for you. Cheers! |
Beta Was this translation helpful? Give feedback.
Hey @kde99, thanks for your question.
I'm afraid the
getQuickEditForm()
method is not the right place for adding the fields. The documentation mentions two different places for defining them:In your case, as you want to set some defaults from the main entity, the first option is suitable for you where you define a
setupQuickEditOperation()
method in your Crud Controller like below: