title: How do you create partially pre-filled forms with Rails, Simple_Form, and Cocoon?
body: <p>I have a form to collect CV information from Users. In it, I need to gather what languages they speak and their proficiency level with each. I want to have 3 languages that are required, already present on the form, and have the option to allow the User to add additional languages. Cocoon works great for allowing them to add languages on their own, but, how can I get 3 language instances already in the form?</p>
  
  <h3>cvs/_form.html.haml</h3>
  
  <pre><code>= simple_form_for(@cv, url: user_cvs_path) do |f|
  
      ...
  
      %hr
      .row
        %strong Please indicate known languages and ability level in each:
        #languages
          = f.simple_fields_for :languages do |language|
            = render 'language_fields', f: language
          .links
            = link_to_add_association 'Add Language', f, :languages, class: 'btn btn-success btn-sm'
  
      ...
  </code></pre>
  
  <h3>cvs/_language_fields.html.haml</h3>
  
  <pre><code>.row.nested-fields
    = f.input :name, wrapper_html: { class: 'col-sm-4' }
    = f.input :read, collection: @language_levels, wrapper_html: { class: 'col-sm-2' }
    = f.input :write, collection: @language_levels, wrapper_html: { class: 'col-sm-2' }
    = f.input :speak, collection: @language_levels, wrapper_html: { class: 'col-sm-2' }
    = f.input :listen, collection: @language_levels, wrapper_html: { class: 'col-sm-2' }
    = link_to_remove_association "Remove Language", f
  </code></pre>
  
  <p>In it's present state, this section of the form looks like this:
  <a href="https://i.stack.imgur.com/i8RZQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i8RZQ.png" alt="Form showing only the Add language link"></a></p>
  
  <p>But what I want is this:
  <a href="https://i.stack.imgur.com/nGMye.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nGMye.png" alt="Form with three languages already added to the form"></a></p>
  
  <p>Based on Pablo's answer, I've added this to my controller:</p>
  
  <pre><code>def new
    @cv = @user.build_cv
    @cv.languages.build(name: 'English')
    @cv.languages.build(name: 'Cantonese')
    @cv.languages.build(name: 'Mandarin')
  end
  </code></pre>
  
  <p>That get's me this far:
  <a href="https://i.stack.imgur.com/nZ8bF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nZ8bF.png" alt="Form with three languages added but it still has remove language links"></a>
  Now I just need to figure out how to make the languages 'Fixed' so they can't be changed and I need to get rid of the "Remove Language" links that Cocoon supplies.</p>