Newer
Older
dmpopidor / app / views / answers / _new_edit.html.erb
<%# locals: { question, answer, readonly } %>
<!--
  This partial creates a form for each type of question. The local variables are: plan, answer, question, readonly
-->
<%= form_for answer, url: {controller: :answers, action: :create_or_update}, html: {method: :post, 'data-autosave': question.id, class: 'form-answer' } do |f| %>
  <% if !readonly %>
    <%= f.hidden_field :plan_id %>
    <%= f.hidden_field :question_id %>
    <%= f.hidden_field :lock_version %>
  <% end %>
  <!--Example Answer area -->
  <% annotation = question.first_example_answer %>
  <% if annotation.present? && annotation.text.present? %>
    <div class="panel panel-default">
      <span class="label label-default">
        <%="#{annotation.org.abbreviation} "%> <%=_('example answer')%>
      </span>
      <div class="panel-body">
        <%= raw annotation.text %>
      </div>
    </div>
  <% end %>
  <fieldset <%= 'disabled' if readonly %>>
    <% if question.option_based? %>
        <%= render(partial: 'questions/new_edit_question_option_based', locals: { f: f, question: question, answer: answer }) %>
    <% elsif question.question_format.textfield?%>
        <%= render(partial: 'questions/new_edit_question_textfield', locals: { f: f, question: question, answer: answer }) %>
    <% elsif question.question_format.textarea? %>
        <%= render(partial: 'questions/new_edit_question_textarea', locals: { f: f, question: question, answer: answer }) %>
    <% end %>
    <%= f.button(_('Save'), class: "btn btn-default", type: "submit") %>
  </fieldset>
<% end %>