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 hidden field customization support #232

Closed
wants to merge 1 commit into from

Conversation

excid3
Copy link
Contributor

@excid3 excid3 commented Dec 16, 2024

I needed a way to specify extra attributes on the hidden field. For example, specifying the form attribute to target a specific form on the page.

This adds the ability to specific extra attributes on hidden_field the same way that input works.

  <%= combobox_tag :id, users_path, placeholder: "Search users", hidden_field: {form: :user} %>

@josefarias
Copy link
Owner

Thanks @excid3! I think the built-in (and undocumented — I really have to get on that 🤦‍♂️) customizable concern should be able to handle this as follows:

<%= combobox_tag :id, users_path do |combobox| %>
  <% combobox.customize_hidden_field form: :user %>
<% end %>

Does that work for you?

@excid3
Copy link
Contributor Author

excid3 commented Dec 16, 2024

I wondered about that. I'm fine using that instead. 👍

@excid3 excid3 closed this Dec 16, 2024
@excid3
Copy link
Contributor Author

excid3 commented Dec 16, 2024

On an unrelated note, is there a way to clear the combo box from a turbo_stream action? I have a reset_form action that runs form.reset(), but that doesn't seem to trigger a reset of the combobox.

@josefarias
Copy link
Owner

@excid3 not currently, but there's been requests for that. I do see us supporting it eventually.

The stopgap solution I've given is to replace the combobox altogether with a fresh one. Hopefully that works as a stopgap solution.

@excid3
Copy link
Contributor Author

excid3 commented Dec 16, 2024

Cool, that's what I figured I'd do for now. 👍

@excid3 excid3 deleted the customize-hidden-field branch December 16, 2024 17:19
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