formulator icon indicating copy to clipboard operation
formulator copied to clipboard

Configurable field order

Open jonathonadler opened this issue 3 years ago • 2 comments

Currently, it is only possible to output fields in order [label, input, error]. My project CSS required the label to be rendered after the input field i.e. [input, label, error].

I had to override the whole formulator module to overcome this:

  defp build_input_and_associated_tags(form, field, label_options, fun) do
    error = HtmlError.html_error(form, field)
    [
      fun.(error),
      build_label(form, field, label_options), # JA, swap label position
      error.html
    ]
    |> Enum.reject(&(is_nil(&1)))
  end

It would be great if order was configurable.

jonathonadler avatar May 16 '21 10:05 jonathonadler

Since you did it this way, it sounds like across your entire project you always put the label after the field. Do you think there is a case for this to be configurable at the input level? eg, only for text fields reorder the elements? or eg only for this field reorder the element?

dbernheisel avatar May 23 '21 17:05 dbernheisel

That’s correct. For my project, I would like to change the field order globally. I imagine there will be exceptions from to time though, so a per field override would also be very helpful.

Thanks for taking the time to look into this!

jonathonadler avatar May 23 '21 22:05 jonathonadler