Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement HTML specification on form attributes. #6399

Closed
ericovasconcelos opened this issue Jun 28, 2021 · 2 comments
Closed

Implement HTML specification on form attributes. #6399

ericovasconcelos opened this issue Jun 28, 2021 · 2 comments

Comments

@ericovasconcelos
Copy link

ericovasconcelos commented Jun 28, 2021

Is your feature request related to a problem? Please describe.
When dealing with file upload sometimes it is necessary to override content-type (enctype) and http verb (method) to provide a full support. For example, in PHP you can not use PUT to send a file (https://www.php.net/manual/en/features.file-upload.put-method.php), so you will need to override to POST verb even on a REST update operation.

Describe the solution you'd like
The solution is already specified on HTML specification. To use enctype (or formenctype on button) and method (or formmethod on button) on the form tags.

Today, even if you force that the HTML form generated by react components on react-admin follow those specifications (it would be good to have a props on the form element and create and edit buttons to be able to provide those options, but for this issue, lets assume we got a form with those defaults HTML attributes), the current dataProvider interface will discard those informations and get only the parsed data from the input and the resource name.

Describe alternatives you've considered
Currently, I'm following a workaround using a verification based on the resource name and forcing a change on those attributes overwriting the default dataProvider httpClient parameters on those case. I know I can also use transform to send some trigger data). But it looks a little dirty to depend on a name validation or even on a data transform to provide it as it is standard HTML specifications and should be more standard interface way to do it.

It would be better if there is a defined way on the dataProvider interface to receive html form attributes and deliver for dataProvider (maybe add it on params key?)

@fzaninotto
Copy link
Member

Hi, and thanks for this suggestion.

React-admin doesn't speak HTTP. It speaks dataProvider. If you want to pass information from the UI to the dataProvider, you'll have to do it via hidden inputs, localStorage, or any other means, and do the translation to HTTP in your dataProvider.

See the underlying design choices at https://marmelab.com/react-admin/Architecture.html#providers

@ericovasconcelos
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants