PhoenixBootstrapForm Hex.pm Build Status

Format your application forms with Bootstrap 4 beta markup.

Installation

Add phoenix_bootstrap_form to your list of dependencies in mix.exs:

def deps do
[{:phoenix_bootstrap_form, "~> 0.0.1"}]
end

You may also alias this module in web.ex so it's shorter to type in templates.

alias PhoenixBootstrapForm, as: PBF

Usage

In order to change markup of form elements to bootstrap-style ones all you need is to prefix regular methods you aleady have with PhoenixBootstrapForm, or FBF if you created an alias. For example, this vanilla form:

<%= form_for @changeset, "/", fn f -> %>
<%= text_input f, :value %>
<% end %>

Becomes bootstrap-styled:

<%= form_for @changeset, "/", fn f -> %>
<%= PBF.text_input f, :value %>
<% end %>

You can always fall-back to default Phoenix.HTML.Form methods if bootstrapped ones are not good enough.

Currently this module supports following methods:

For quick reference you can look at this template. You can mix phx.server inside dummy folder to see this reference template rendered.


Copyright 2017, Oleg Khabarov