phoenix_mtm v0.4.2 PhoenixMTM.Helpers

Provides HTML helpers for Phoenix.

Summary

Functions

Generates a list of checkboxes and labels to update a Phoenix many_to_many relationship

Functions

collection_checkboxes(form, field, collection, opts \\ [])

Generates a list of checkboxes and labels to update a Phoenix many_to_many relationship.

Basic Example

<%= PhoenixMTM.Helpers.collection_checkboxes f, :tags,
      Enum.map(@tags, &({&1.name, &1.id})),
      selected: Enum.map(f.data.tags, &(&1.id)) %>

Custom <input> and <label> options

<%= PhoenixMTM.Helpers.collection_checkboxes f, :tags,
      Enum.map(@tags, &({&1.name, &1.id})),
      selected: Enum.map(f.data.tags, &(&1.id)),
      label_opts: [class: "form-input"], input_opts: [class: "form-control"] %>

Options

  • :nested - when passed true, the label will be wrapped around the checkbox