Skip to content
master
Go to file
Code

Latest commit

Previously dependabot was updating our ex_doc dependency past 0.18.x,
but versions past 0.18 require Elixir 1.7. This is the error message
that comes up when trying to generate docs,

> (ExDoc.Retriever.Error) ExDoc 0.19+ requires Elixir v1.7 and later.
For earlier Elixir versions, make sure to depend on {:ex_doc, "~>
0.18.0"}

We set `:ex_doc` to `~> 0.18.0` in this commit.
c33413c

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
bin
 
 
 
 
doc
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

CircleCI

Formulator

Formulator is part of the thoughtbot Elixir family of projects.

This README follows master, which may not be the currently published version. Here are the docs for the latest published version of Formulator

Usage

Formulator is a library for Phoenix to give you:

  • A label for your input, based on the attribute name
  • An error label
  • A class around the input if there is an error for the attribute. This allows you to easily style inputs that have errors.

You can replace the following:

  <%= label form, :name %>
  <%= text_input form, :name %>
  <%= error_tag form, :name %>

with this:

  <%= input form, :name %>

You also get the added benefit of having a class of has-error on the input when there is an error associated with the attribute.

By default, Formulator assumes that you want a standard text input but if you prefer, you can also specify the input type:

  <%= input form, :description, as: :textarea %>
  <%= input form, :count, as: :number %>
  <%= input form, :email_address, as: :email %>

See Formulator.input/3 for more examples.

Installation

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

  def deps do
    [
      {:formulator, "~> 0.1.8"},
    ]
  end
  $ mix deps.get

Formulator needs to know what module to use for the translate_error/1 function. This is commonly defined by Phoenix either in web/views/error_helpers.ex or web/gettext.ex. Formulator can also be set to not validate by default; individual input options override the application config.

  # config/config.exs
  config :formulator,
    translate_error_module: YourAppName.ErrorHelpers,
    validate: false, # defaults to true
    validate_regex: false,  # defaults to true
    wrapper_class: "input-set"  # defaults to nil

You can import the package into all your views or individually as it makes sense:

  # web/web.ex
  def view do
    quote do
      ...
      import Formulator
      ...
    end
  end

Releases

To create a new release, use the bin/release script. You must provide the current version number and the new version number: bin/release 0.2 0.3.

If you need hex permissions, please ask someone in the thoughtbot #elixir slack channel.

This will create a new commit with the updated fields and publish to hex.

Please be sure to follow Semver when creating a new release

Contributing

See the CONTRIBUTING document. Thank you, contributors!

License

Formulator is Copyright (c) 2017 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About

thoughtbot

Formulator is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software, Elixir, and Phoenix. See our other Elixir projects, or hire our Elixir/Phoenix development team to design, develop, and grow your product.

About

A form library for Phoenix

Topics

Resources

License

Releases

No releases published

Sponsor this project

 
Learn more about GitHub Sponsors
You can’t perform that action at this time.