title: simple_fields_for was remove once the validation occur
body: <p>I need some help.</p>
  <p><code>&quot;= form.association :lead&quot;</code> : the user can select a lead through select2 via ajax.</p>
  <p><code>.lead-form-inputs</code> : the user can create a lead and automatically set the lead_id of the property once it was submitted.</p>
  <p>I do have a select2 gem installed and runs the<code>&quot;= form.association :lead&quot;</code> as a select2.
  As you can see there was a :new_lead input as a boolean(a Checkbox).
  Once the checkbox is checked the <code>&quot;= form.association :lead&quot;</code> will disappear and the <code>.lead-form-inputs</code> class will appear.</p>
  <p>PROBLEM:</p>
  <ol>
  <li>Once i submitted the form(on purpose) just to trigger the validation. The <code>= form.simple_fields_for :lead do | lead_builder |</code> entire inputs is removed.</li>
  </ol>
  <blockquote>
  <p>I need that <code>form.simple_fields_for</code> to stay because if the user want to create another lead yet the validations has been triggered the <code>form.simple_fields_for</code> is not present. Yet still the user can go to the property/new just to refresh the entire page.</p>
  </blockquote>
  <ol start="2">
  <li>If i select a lead using the <code>&quot;= form.association :lead&quot;</code> and submitted the form(on purpose) just to trigger the validation. The <code>form.simple_fields_for</code> stays but <code>&quot;= form.association :lead&quot;</code> is empty.
  I said earlier that &quot;i select a lead&quot;. Once i checked the checkbox. The <code>form.simple_fields_for</code> inputs was filled in. The information filled in to the inputs is that the lead i selected earlier after i submitted the form.</li>
  </ol>
  <blockquote>
  <p>What i want is that the select2 will still display the lead what i selected.</p>
  </blockquote>
  <p>VIEW:</p>
  <pre><code>= simple_form_for([:admin, @property], wrapper: :vertical_form, html: { autocomplete: &quot;off&quot;, class: &quot;primary-form&quot; }) do |form|
    = form.input :listing_title
    = form.association :lead, collection: [], input_html: { multiple: false }, label: false
  
    = form.simple_fields_for :lead do | lead_builder |
      = lead_builder.input :new_lead, as: :boolean
      .lead-form-inputs.hide
       = lead_builder.input :status, collection: [['New Lead', 'New Lead'], ['SLC', 'SLC'], ['BLC', 'BLC'], ['Seller Lead', 'Seller Lead'], ['Buyer Lead', 'Buyer Lead'], ['Client', 'Client'], ['Shelf', 'Shelf'], ['Drop', 'Drop']], prompt: &quot;Select Status&quot;
       = lead_builder.input :last_name
       = lead_builder.input :first_name
       = lead_builder.input :middle_initial
       = lead_builder.input :contact_number
       = lead_builder.input :email_address
       = lead_builder.input :company_name
       = lead_builder.input :date_inquired do
       = lead_builder.text_field :date_inquired, class: &quot;datepickerJs&quot;, value: @property.lead.date_inquired.blank? ? '' : @property.lead.date_inquired.strftime(&quot;%b-%d-%Y&quot;)
       = lead_builder.input :source, collection: [['Website', 'Website'], ['Facebook', 'Facebook'], ['Facebook Ads', 'Facebook Ads'], ['DotProperty', 'DotProperty'], ['Referral', 'Referral'], ['Network', 'Network'], ['Old Leads', 'Old Leads']], prompt: &quot;Select Source&quot;
    = form.submit &quot;Save&quot;, class: &quot;button action-button__save-button primary-form__submit-btn&quot;
  
  :javascript
    $( &quot;#property_lead_id&quot; ).select2({
      closeOnSelect: true,
      allowClear: true,
      placeholder: &quot;Select lead&quot;,
      minimumInputLength: 1,
      ajax: {
        url: '/admin/leads.json',
        data: function (params) {
          var query = {
            search: params.term,
          }
          return query;
        },
        processResults: function (data) {
          return {
            results: $.map(data.leads, function(obj, key) {
              responsejson = {
                  id: obj.id,
                  text: `${obj.first_name} ${obj.middle_initial} ${obj.last_name}`,
              };
              return responsejson;
            })
          };
  
        }
      }
    });
  </code></pre>
  <p>Property CONTROLLER:</p>
  <pre><code>def new
   @property = Property.new
   @lead = @property.build_lead
  end
  
  def create
   @property = Property.new(property_params)
   respond_to do |format|
    if @property.save
     format.html { redirect_to edit_admin_property_path(@property), notice: 'Property was successfully created.' }
    else
     format.html { render :new }
    end
   end
  end
  
  def property_params
    params.require(:property).permit(:listing_title, :lead_id, lead_attributes: [:id, :status, :last_name, :first_name, :middle_initial, :contact_number, :email_address, :company_name, :date_inquired, :source, :new_lead])
  end
  </code></pre>
  <p>MODELS:</p>
  <pre><code>class Property &lt; ApplicationRecord
   belongs_to :lead
   accepts_nested_attributes_for :lead, reject_if: :reject_lead
  
   def reject_lead(attributes)
      attributes[&quot;new_lead&quot;] != '1'
    end
  end
  
  class Lead &lt; ApplicationRecord
   attr_accessor :new_lead
  
   has_many :properties
   
   validates :status,
              :last_name,
              :first_name,
              :middle_initial,
              :contact_number,
              :email_address,
              :company_name,
              :date_inquired,
              :source,
              presence: true
  end
  </code></pre>