formex v0.1.4 Formex.View

Helper functions for templating.

Example of use:

<%= formex_form_for @form, @action, fn f -> %>
  <%= if @form.changeset.action do %>
    <div class="alert alert-danger">
      <p>Oops, something went wrong! Please check the errors below.</p>
    </div>
  <% end %>

  <%= formex_rows f %>

  <div class="form-group">
    <%= submit "Submit", class: "btn btn-primary" %>
  </div>
<% end %>

Summary

Functions

Generates a row with Bootstraps’s .form-group class. Example os use

Generates a row with Bootstraps’s .form-group class. Should be used with .form-horizontal class

Generates all rows at once

Generates all rows at once

Functions

formex_form_for(form, action, options \\ [], fun)

Works similar to Phoenix.HTML.Form.form_for/4

In callback first argument is Formex.Form.t/0 instead of Phoenix.HTML.Form.t/0. This argument contains a Phoenix.HTML.Form.t/0 under :phoenix_form key

formex_row(form, field_name)

Generates a row with Bootstraps’s .form-group class. Example os use:

<%= formex_row f, :title %>
<%= formex_row f, :content %>
<%= formex_row f, :category_id %>
formex_row_horizontal(form, field_name)
formex_row_horizontal(Formex.Form.t, Atom.t) :: Phoenix.HTML.safe

Generates a row with Bootstraps’s .form-group class. Should be used with .form-horizontal class.

<div class="form-horizontal">
  <%= formex_row_horizontal f, :title %>
  <%= formex_row_horizontal f, :content %>
  <%= formex_row_horizontal f, :category_id %>
</div>
formex_rows(form)

Generates all rows at once

formex_rows_horizontal(form)

Generates all rows at once