Hello folks,
I have these phoenix routes…
get "/fetch_data", MyController, :fetch_index
post "/fetch_preview", MyController, :fetch_preview
put "/fetch_submit", MyController, :fetch_submit
In fetch_data route I upload a csv
file using a template and transform into a struct like my_struct = %my_struct{data:[...], is_valid: true, name: "data"}
Then, I render another template (in fetch_preview
function inside MyController
) :
render conn, "fetch_preview.html", my_struct: my_struct
<div>
<span> my_struct name: </span> <%= my_struct.name %>
</div>
<div>
<span> Is_valid: </span> <%= my_struct.is_valid %>
</div>
<div class="">
<%= form_for @conn, fetch_path(@conn, :fetch_submit),
[as: :fetch], fn f -> %>
#Here how can I set a data to get in fetch_submit function??
# @conn = Map.put(@conn,"mydata", my_struct) ??
</label>
<br>
<%= submit "Review and Continue the Submit" %>
<% end %>
Here, how can properly set and get the param[“mydata”]???
def fetch_submit(conn, params) do
Map.get(params,"fetch")
|> Map.get("mydata") #this will raise a `Nil exception`
end