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

Form component needs more extensive documentation #134

Open
oskargargas opened this issue Sep 16, 2024 · 1 comment
Open

Form component needs more extensive documentation #134

oskargargas opened this issue Sep 16, 2024 · 1 comment

Comments

@oskargargas
Copy link

I'm using v1 branch and reading docs at https://rbui.dev/docs/form

Form component is very lightly documented. Documentation shows how to visually build the form but misses the most important stuff - interaction. By looking through code I was able to find way to pass action, HTTP method nad input names but this stuff should be documented for ease of use.

In best case scenario I'd see docs expanded by at least 2 examples.

  1. Simple, 1 field form, complete with action names, etc.
  2. Complex real world example, ex. Devise login form
@cirdes
Copy link
Collaborator

cirdes commented Sep 23, 2024

@oskargargas, you make a valid point. It would be nice to document forms a bit more thoroughly.

Right now, I'm using forms with form_with helpers, but we have to define the input names ourselves.

form_with(url: buyer_setting_groupers_path(@setting_grouper.buyer)) do
  FormField(class: "flex-1") do
    FormFieldLabel(for: "setting_grouper[display_name]") { "New group" }

    div(class: "flex flex-row items-center justify-between gap-4") do
      Input(
        required: true,
        id: "setting_grouper[display_name]",
        name: "setting_grouper[display_name]",
        placeholder: "Fill here."
      )
    end

    FormFieldError { @setting_grouper.errors.full_messages_for(:display_name).first }
  end

  Button(size: :sm, type: "submit") { "Create" })
end

I have opened this PR on Rails to try to access the input attributes to make integration with Rails even easier, but it hasn't been merged yet.

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