But I would like more control over what is inside the <button></button> tag – I would like to add a bunch of other HTML inside the button tag, including some SVG images.
How can I add my own SVG tags inside the button tag while still using the Phoenix.HTML.Form module as a helper to generate the button.
Or does it just not make sense for me to use the <%= submit "Log in" %> shortcut for my case? Since I’m doing everything within the form_for function, I’d like to be consistent with the way I generate other form elements, and also make sure I have my form all tied together properly.
Currently I pass information to the submit form helper so that I can style the button by setting the class.
<%= submit "Log in", class: "styling" %>
How can I set the class on the button if I jump directly into the do-end block?
Also, under what scenario do I gain a big advantage from using this submit helper from Phoenix.HTML.Form? It seems to me like it doesn’t really help much – it seems like different syntax for saying the same thing and I’m getting no magic lifting happening for me behind the scenes.
In a Phoenix Liveview leex file, I reference an SVG in the button tag, then use CSS to style the button shape/color and the SVG attributes, such as position. Also, the button is disabled if the associated input field value is blank.
<button class="post_send_button" type="submit" name="submit" <%= if @post == "" do %>disabled="disabled"<% end %>>
<img class="send_img" src="<%= Routes.static_path(@socket, "/images/icons/send_white.svg") %>"/>
</button>
Following is CSS that renders a round button with the SVG centered, and to the right side of the associated input assigned a class value of post_send: