Beginner here.
Elixir: 1.10.4
Pheonix: 1.5.4
I am experimenting with templates and tailwind css in Phoenix.
Here the render function I am using in my template to display an input_text:
<%= render "_text_input.html", f: f, field: :alpha2 %>
And here the partial template:
<div class="col-span-6 sm:col-span-6 lg:col-span-2">
<label for="#{Atom.to_string(@field)}" class="block text-sm font-medium leading-5 text-gray-700">
<%= label @f, @field %>
</label>
<%= text_input @f, @field, class: "mt-1 form-input block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:text-sm sm:leading-5 uppercase ", minlength: "2", maxlength: "2" %>
<%= error_tag @f, @field %>
</div>
What I would like to acheive is modify the <%= form_for @changeset, @action, fn f -> %>
so that I can
a) add additional class attributes to partial, e.g. the uppercase class attribute, or the lg:col-span-2 .
b) add optional parameters such as , minlength: "2"
that are only valid is very specific cases, where the value of the minlength or maxlength can be passed as a parameter.
This was I can have a standard look and feel for an input field, and when I need a <%= text_input f, :alpha2 %>
for example I cann call my partial template for the test input field, with appropriate class parameters modifying the look and action of the field.
Perhaps this has been handled in a blog post that someone could point me to, but so far I have not been able to find something that would help me with this specific issue. Perhaps my idea for a solution here is too simplistic, and other solutions would make more sense here. Any help appreciated.