Question about Phoenix.HTML.Link

I am using this link in html.eex
<span><%= link "Delete", to: phonebook_person_path(@conn, :delete, @phonebook.id, person.id), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>

but I want to change that link to material floating action button like this.

<span><a data-to="<%= phonebook_person_path(@conn, :delete, @phonebook.id, person.id) %>" class="btn-floating btn-small red" data-method="delete" data-confirm="Are you sure?"><i class="material-icons">delete</i></a></span>

I can add data-to, data-method, data-confirm manually, but how can I add csrf token ? since it is generated automatically by default when using Phoenix.HTML.Link.

A delete method on a link turns it into a form, so just use the normal form_for calls to operate on a @conn as usual, then you can customize your link all you want. I do that for my Surface CSS Elixir module. :slight_smile:

Oh ok. So I tried.

<%= form_for @conn, phonebook_person_path(@conn, :delete, @phonebook.id, person.id),[method: :delete], fn f -> %>
   <a class="btn-floating btn-small red"  data-confirm="Are you sure?"><i class="material-icons">delete</i></a>
<% end %>

and it turns out to be like this

<form accept-charset="UTF-8" action="/dashboard/phonebooks/17/people/23" method="post">
  <input name="_method" value="delete" type="hidden">
  <input name="_csrf_token" value="FyQuOXp/Fn96N1QsQj8ZKQ1+JAhyAAAABvFHN5gO0n1J8WrEe1tCBw==" type="hidden">
  <input name="_utf8" value="✓" type="hidden">          
  <a class="btn-floating btn-small red" data-confirm="Are you sure?"><i class="material-icons">delete</i></a>
</form>

but delete button doesn’t work :cold_sweat:

You can just do this: Bootstrap link vs phoenix link `<%= link ..`

What part and how?