add doc about filterHandler
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
008db638b2
commit
f2ba285349
|
@ -72,9 +72,9 @@ Override a view.
|
||||||
| `form_widget` | `@Core/admin/crud/_form_widget.html.twig` | Template to render a form widget |
|
| `form_widget` | `@Core/admin/crud/_form_widget.html.twig` | Template to render a form widget |
|
||||||
| `form_translations` | `@Core/admin/crud/_form_translations.html.twig` | Template to render a the translation field |
|
| `form_translations` | `@Core/admin/crud/_form_translations.html.twig` | Template to render a the translation field |
|
||||||
|
|
||||||
| Entity (context) | View | Description |
|
| Entity (context) | View | Description |
|
||||||
| ------ | ---- | ----------- |
|
| ------ | ---- | ----------- |
|
||||||
| `show_entity` | `@Core/admin/crud/_show.html.twig` | | Template to render the entity |
|
| `show_entity` | `@Core/admin/crud/_show.html.twig` | Template to render the entity |
|
||||||
|
|
||||||
## setViewDatas
|
## setViewDatas
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,14 @@ public function upload(Request $request, FileUploadHandler $fileUpload)
|
||||||
$keepOriginalFilename = false;
|
$keepOriginalFilename = false;
|
||||||
|
|
||||||
$fileUpload->handleForm(
|
$fileUpload->handleForm(
|
||||||
$form->get('image')->getData(), // Symfony\Component\HttpFoundation\File\UploadedFile or null
|
uploadedFile: $form->get('image')->getData(), // Symfony\Component\HttpFoundation\File\UploadedFile or null
|
||||||
$fileDirectory,
|
path: $fileDirectory,
|
||||||
// optional
|
// optional
|
||||||
function ($filename) use ($entity, $fileDirectory) {
|
afterUploadCallback: function ($filename) use ($entity, $fileDirectory) {
|
||||||
$entity->setImage($fileDirectory.$filename);
|
$entity->setImage($fileDirectory.$filename);
|
||||||
},
|
},
|
||||||
// optional
|
// optional
|
||||||
$keepOriginalFilename
|
keepOriginalFilename: $keepOriginalFilename
|
||||||
);
|
);
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
@ -36,3 +36,13 @@ public function upload(Request $request, FileUploadHandler $fileUpload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you need to generate custom filenames, `FileUploadHandler` allows you to define a generator:
|
||||||
|
|
||||||
|
```
|
||||||
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
|
|
||||||
|
$fileUpload->setFilenameGenerator(function(UploadedFile $file) {
|
||||||
|
return sprintf('%d.%s', mt_rand(), $file->guessExtension());
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue