Episodes
ewanchic PRO said about 1 year ago on Building a Questionnaire :
nested_form_controller.js is in the wrong location. In the Show Notes tab, you have it listed as:

# app/assets/javascripts/nested_form_controller.js

Instead, it should be:
# app/assets/javascripts/controllers/nested_form_controller.js







David Kimura PRO said about 1 year ago on Building a Questionnaire :
  ewanchic  Thanks for the catch. I've updated the show notes to reflect this.

Tom PRO said 11 months ago on Building a Questionnaire :
Hi,

Having an annoying issue on this one - it looks like adding multiple answers to a question when creating a new questionnaire causes only the last answer to be accepted (only shows one in the dev log in the request too),  but it works fine when editing an existing questionnaire. It looks like 'Add answer' is creating multiple of the same block of HTML when creating a new questionnaire, i.e. 

var content = this.templateTarget.innerHTML.replace(/TEMPLATE_RECORD/g, new Date().getTime())

in nested_form_controller.js appears not to be working correctly (I think) - even when directly copy/pasting from the code blocks above, but only for new questionnaires. Any ideas?

David Kimura PRO said 11 months ago on Building a Questionnaire :
It’s addressed in the next episode in dealing with nested attributes within nested attributes 

Nate said 4 months ago on Building a Questionnaire :
Hi David! I'm wondering what would you suggest doing in the case that I would like to render the same

<%= form.text_field :name, placeholder: 'Answer', class: 'form-control' %>

answer field in the long answer div i.e

  <div data-controller="nested-form" data-dynamic-select-target='long'>
     <%= form.fields_for :answers, Answer.new do |answer| %>
       <%= answer.text_field :name, placeholder: 'Answer', class: 'form-control' %>
      <% end %>
  </div>

I've played with this, but this keeps causing problems since it will submit answer the form everytime with one empty field also. Any suggestions?

Nate said 4 months ago on Building a Questionnaire :
I'm having a bit of trouble understanding how can you place anything related to the form under the long target as this will always submit empty data form either of the form since other one of them is just hidden not removed from the DOM.

Login to Comment