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

CreateGuesser / EditGuesser formId attribute to bind outher input elements #540

Closed

Conversation

PawelSuwinski
Copy link
Contributor

Possibility to set guesser's form id using formId attribute. It allows to place any input element outside the form.

Example of submit button on the AppBar (just to show the idea, whole implementation uses React.createPortal() and a bit more code):

const AppBar  = () => (
   /...
  <SaveButton form="user-form" />
);
// ...

const UserCreate = () => (
    <CreateGuesser formId="user-form" (...)>
     // ...
    </CreateGuesser>
);

obraz

@fzaninotto
Copy link
Contributor

In my opinion, the Guesser should only get you started, and then you should paste its code and customize it. Otherwise, it will become some kind of "god component", which goes against the philosophy of react-admin.

@PawelSuwinski
Copy link
Contributor Author

PawelSuwinski commented Mar 27, 2024

In my opinion, the Guesser should only get you started, and then you should paste its code and customize it. Otherwise, it will become some kind of "god component", which goes against the philosophy of react-admin.

In generall you are right but api-platform Guessers are something more than RA Guessers. There is a override-code message that hints the customization (

const getOverrideCode = (schema: Resource, fields: Field[]) => {
) but there are also introsopection, transform, save and other callbacks that form needs, and it was afterall the goal of the api-platform, as a kind of low-code, not to assembly to many things by hand (hydra, schema.org etc). Maybe it should be named in other way then guessers, or all those callbacks should be exported as hooks, but now it is not.

@PawelSuwinski
Copy link
Contributor Author

@fzaninotto your comment made me want to do some refactoring (#542) to makes easier to write custom form components, so please give some feedback about that.

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

Successfully merging this pull request may close these issues.

2 participants