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

add options attribute to inputs_for/1 #2981

Merged
merged 1 commit into from
Jan 3, 2024
Merged

add options attribute to inputs_for/1 #2981

merged 1 commit into from
Jan 3, 2024

Conversation

woylie
Copy link
Contributor

@woylie woylie commented Jan 3, 2024

Phoenix.HTML.FormData.to_form/4 allows for arbitrary protocol-specific options to be passed in the fourth argument. Phoenix.Component.inputs_for/1 currently only supports options specific to the protocol implementation for Ecto.Changeset. This PR adds a new options attribute that can be used to pass any additional options for other implementations.

Context: Flop.Phoenix implements the FormData protocol for the Flop.Meta struct and relies on a fields option to be passed. This is currently only possible with the inputs_for/4 function that was moved to PhoenixHTMLHelpers, but not with the inputs_for component.

Relates to woylie/flop_phoenix#299.

@josevalim
Copy link
Member

For completeness, can you give an example of the options you would pass here?

@woylie
Copy link
Contributor Author

woylie commented Jan 3, 2024

For completeness, can you give an example of the options you would pass here?

In the case of Flop.Phoenix, you can pass additional options like the filter operators: fields: [{:email, op: :ilike}]. The FormData implementation adds the operator to form.hidden.

@josevalim josevalim merged commit 42ef155 into phoenixframework:main Jan 3, 2024
4 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@woylie woylie deleted the inputs-for-options branch January 4, 2024 03:34
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