Newer
Older
dmpopidor / app / views / branded / shared / dynamic_form / _modal.html.erb
<% url = @fragment.new_record? ?  madmp_fragments_path : madmp_fragment_path(id: @fragment.id) %>
<% parent_id = @parent_fragment.id unless @readonly %>
<div class="modal-dialog madmp-fragment" role="document">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
    <%= form_for @fragment, url: url,
                        html: {
                          method: @fragment.new_record? ? :post : :put, 
                          remote: true, 
                          class: 'form-horizontal', 
                          id: "modal_fragment_form" 
                        } do |f| %>  
      <%= f.hidden_field :dmp_id, id: nil %>
      <%= f.hidden_field :parent_id, :value => parent_id, id: nil %>
      <%= f.hidden_field :id, id: nil %>
      <%= f.hidden_field :schema_id, :value => @schema.id, id: nil%>
      <%= f.hidden_field :template_locale, :value => @template_locale, id: nil%>
      <%= f.hidden_field :property_name, :value => @property_name, id: nil%>
      <%= f.hidden_field :query_id, :value => @query_id, class: "query_id", id: nil%>
      <%= f.hidden_field "source", :value => @source %>
      <div class="modal-body">
        <fieldset aria-labelledby="fragment-fieldset" <%= 'disabled' if @readonly %> >
          <%= render(partial: "shared/dynamic_form/form", locals: {
            f: f,
            current_fragment: @fragment, 
            schema: @schema,
            question_id: nil,
            classname: @classname,
            readonly: @readonly,
            form_prefix: nil,
            template_locale: @template_locale,
            source: @source
          })%>
        </fieldset>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal"><%= _('Close') %> </button>
        <%= f.button(_('Submit'), class: "btn btn-primary", type: "submit") unless @readonly %>
      </div>
    <% end %>
  </div>
</div>