Skip to content

Undefined local variable or method `__nested_field_for_replace_with_index__' #89

@humphreybc

Description

@humphreybc

I am trying to set multiple placeholders, one for each form field, from an array of placeholders. It sounds like the __nested_field_for_replace_with_index__ string would be useful, but I'm getting the following error:

undefined local variable or method `__nested_field_for_replace_with_index__' for #<#<Class:0x007f7fa3821188>:0x007f7f9ef8a578>

Here's my code:

/ _form.html.haml
= vertical_form_for study, url: study_questions_path(study.slug), method: :post do |f|
  = f.nested_fields_for :questions do |question|
    = render partial: 'form_fields', locals: { f: question, placeholder: Question::PLACEHOLDERS[__nested_field_for_replace_with_index__] }

/_form_fields.html.haml
= f.input :body, placeholder: placeholder, label: 'Open-ended question', as: :text, input_html: { class: 'question-textarea' }

I also tried just putting it there as a string, but then I get no implicit conversion of String into Integer as the error instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions