title: Add and show an error message with Phoenix.HTML.Form "With connection data"
body: <p>I have a simple form with a textarea, where the user will type in (or copy'n'paste) a json string into it. The form will be sent to my controller action and I will validate the json string and if it will be ok, I will create some records and all is fine.</p>
  
  <p>To send the form to my controller action I use <a href="http://hexdocs.pm/phoenix_html/Phoenix.HTML.Form.html" rel="noreferrer">Phoenix.HTML.Form</a> "With connection data" at the moment and therefore I have no model/changeset. </p>
  
  <pre><code>&lt;%= form_for @conn, @action, [as: :match], fn f -&gt; %&gt;
    &lt;%= textarea f, :json, rows: 20 %&gt;
    &lt;%#= error_tag @changeset, f, :json %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>If the json is invalid for some reason, I like to render the form again and display the error message(s). <code>error_tag</code> is a view helper method which will display an error at a field if there's a changeset. Because of this it's commented out now.</p>
  
  <pre><code>def error_tag(form, field) do
    if error = form.errors[field] do
      content_tag :span, (humanize(field) &lt;&gt; " " &lt;&gt; translate_error(error)), class: "help-block"
    end
  end
  
  def error_tag(changeset, form, field) do
    if changeset.action do
      error_tag(form, field)
    end
  end
  </code></pre>
  
  <p>What is a proper way to add an error so that I can display them at a form field. Do I have to add the error to <code>@conn</code> or <code>f</code> (form) or Is there another way to got?</p>