formulator
formulator copied to clipboard
Configurable field order
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.
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?
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!