form_with is one of Rails helper methods and is described in the view file. This method allows you to send information.
You can use form_with to create the required HTML for your input form.
When I looked it up, it seems that the description changes slightly when the sent information is saved in the database and when it is not saved.
** When not saving to database **
ruby:xxx.html.erb
<%= form_with url: "path" do |f| %>
Form contents
<% end %>
** When saving to database **
ruby:xxx.html.erb
<%= form_with(model:Model name, local: true) do |f| %>
Form contents
<% end %>
form_with does not save data You can also use input type elements It seems that you can also use both helper methods to save the data (such as f.text_field).
Finally, I will take an excerpt of what I actually implemented today and keep it as a record.
I hope it will be helpful as a description example.
ruby:xxx.html.erb
<div class="items-sell-main">
<h2 class="items-sell-title">Enter product information</h2>
<%= form_with(model: @product, local: true) do |f| %>
---abridgement---
<%= f.text_area :name, class:"items-text", id:"item-name", placeholder:"Product name (required up to 40 characters))", maxlength:"40" %>
<div class="items-explain">
<div class="weight-bold-text">
Product description
<span class="indispensable">Mandatory</span>
</div>
---abridgement---
</div>
Recommended Posts