Scenario: You have a Comment
schema with an HTML form. After submitting a Comment
's :status
field with a value of approved, display a “Promote” button in the Comment
's show.html.eex
, when upon click, some of the data from the Comment
is posted to the PromotedComments
table.
How would you create a promote button in show.html.eex
that pattern matches comment_id
in the assigns
in order to build the data before inserting to the PromotedComments
table? (I might not be asking the question correctly. Before inserting data into the PromotedComments
table, I need to gather and format some of it, like format the title, compute a comment rating, etc., but this data does not directly come from the form)
<%= form_for @conn, promote_path(@conn, :create), [method: :post], fn f -> %>
....something here....
<%= submit "Promote" %>
<% end %>