getStrippedSaveRequest might not be necessary #316
Replies: 6 comments
-
I am just not sure in the scenario you add 3 fields
In this scenario, $request->validated() would return only What if you don't have any form request for validation of any of the fields? What would be the return of Best, |
Beta Was this translation helpful? Give feedback.
-
If you need If I think there would be a problem is backpack generates zero validation rules... all fields would be ignored
if you don't have a form request then
I got to the conclusion that this might be the right path to go, since that's the code Blueshift generates, have you used it? |
Beta Was this translation helpful? Give feedback.
-
To auto generate validation rules there's this package. Maybe there's a way of using it to fill https://crestapps.com/laravel-code-generator/docs/2.2#how-to-create-form-request |
Beta Was this translation helpful? Give feedback.
-
Hum.. from my understanding
|
Beta Was this translation helpful? Give feedback.
-
I agree with both of you 😂: the way I see it, indeed Though I would love to simplify this part of the saving process, personally I don't think we can remove
So for convenience, for the time being, I'd keep |
Beta Was this translation helpful? Give feedback.
-
Hi. Due to not activity on many years i will close this discussion, if there is needed feel free to reopen or create a new one. Cheers. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Request
What's the feature you think Backpack should have?
$request->validated()
Have you already implemented a prototype solution, for your own project?
yes
Do you see this as a core feature or an add-on?
core feature
The original problem
Old backpack versions performed save operation on
$request->all()
giving way to malicious insertions by adding fields artificially in the request.
(remember @tabacitu ? )
This gave way to
/src/app/Library/CrudPanel/Traits/Fields.php
getStrippedSaveRequest
function which effectively prevents it.However, this might not be necessary by simply using
$request->validated()
https://laravel.com/docs/7.x/validation#form-request-validation
It works, why change?
A common scenario is modifying data just before the insertion.
Or triggering something just after.
This might simplify things a little for novice users.
NOTE: tbh I'm not 100% sure about the
validated()
method and its nuancesBeta Was this translation helpful? Give feedback.
All reactions