Skip to content

How to add ajax toggles index and show pages

Steve Pallen edited this page May 11, 2016 · 2 revisions

Simply add toggle: true to an index column or a show row do display YES NO buttons for a boolean field.

defmodule ContactDemo.ExAdmin.User do
  use ExAdmin.Register
  register_resource ContactDemo.User do
    index do
      column :username
      column :active, toggle: true
    end

    show user do
      attributes_table do
        row :username
        row :active, toggle: true
      end
    end
  end
end

The labels can be customized like:

  row :active, toggle: ~w(On Off)