<% is_template = f.is_a?(OpenStruct) %> <% fields_name = is_template ? "new_clause" : "agreement_blueprint[agreement_clauses_attributes][#{f.index}]" %> <% clause = f.object %>
Clause
<% if is_template %> <%= hidden_field_tag "#{fields_name}[id]", "" %> <%= hidden_field_tag "#{fields_name}[position]", "0", data: { dynamic_clauses_target: "position" } %> <%= label_tag "#{fields_name}[title]", "Clause Title", class: "form-label" %> <%= text_field_tag "#{fields_name}[title]", "", class: "form-control mb-2" %> <%= label_tag "#{fields_name}[content_html]", "Clause Content", class: "form-label" %> <%= text_area_tag "#{fields_name}[content_html]", "", class: "form-control ckeditor", data: { controller: "ckeditor" }, rows: 6 %> <%= hidden_field_tag "#{fields_name}[_destroy]", "0" %> <% else %> <%= f.hidden_field :id %> <%= f.hidden_field :position, data: { dynamic_clauses_target: "position" } %>
<%= f.label :title, "Clause Title", class: "form-label" %> <%= f.text_field :title, class: "form-control" %>
<%= f.label :content_html, "Clause Content", class: "form-label" %> <%= f.text_area :content_html, class: "form-control ckeditor", data: { controller: "ckeditor" }, rows: 6 %>
<%= f.hidden_field :_destroy %> <% end %>