My application allows users to upload a sheet file (xlsx) and I want to allow users to choose which columns (header) they really want to import, and they can also change column name.
Example:
File Header: name, surname, email
Header list to be choose: [{0, “name”, true}, {1, “surname”, true}, {2, “email”, true}]
How can I create a phoenix form that accepts dynamic number of inputs (per column) ?
Their files can contain at least 1 column to several columns (dozens).
Current Controller:
...
conn
|> put_flash(:info, gettext("File uploaded successfully."))
|> render("header.html", id: id, header: select_header)
...
Expected template:
<%= form_for @conn, people_list_path(@conn, :header_create, @locale, @id), [method: :post, as: :header], fn f -> %>
<div class="form-group">
<%= label f, gettext("Index"), class: "control-label" %>
<%= text_input f, :i0, placeholder: gettext("Index"), class: "form-control" %>
<%= error_tag f, :i0 %>
</div>
<div class="form-group">
<%= label f, gettext("Name"), class: "control-label" %>
<%= text_input f, :i1, placeholder: gettext("Name"), class: "form-control" %>
<%= error_tag f, :i1 %>
</div>
<div class="form-group">
<%= label f, gettext("Import"), class: "control-label" %>
<%= checkbox f, :i2, placeholder: gettext("Import"), class: "form-control" %>
<%= error_tag f, :i2 %>
</div>
<div class="form-group">
<div class='control-group'>
<%= submit gettext("Submit"), class: "btn btn-primary" %>
</div>
</div>
<% end %>