ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

2.6.1 safecracker form php error with ft.relationship.php and required fields

July 29, 2013 11:08am

Subscribe [2]
  • #1 / Jul 29, 2013 11:08am

    brittanyA

    184 posts

    I upgraded to 2.6.1 last week and now a safecracker form that was functioning perfectly is running into problems: http://uvamagazine.org/classnotes/submit/

    When I try and submit the form, i get the following errors:

    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Invalid argument supplied for foreach()
    
    Filename: relationship/ft.relationship.php
    
    Line Number: 50

    and

    The form you submitted contained the following errors
    
        The Year field is required.

    ...even though I input that field AND it is not, in fact, required.

    I have tried to dive into ft.relationship.php but I can’t find any documentation of this bug. I can’t seem to attach a .txt to this post, so I’ve posted the portion of my code the character limit will allow below. I think it’s the relevant portion. Thank you for any help!!

    {exp:safecracker 
      channel="classnotes" 
      logged_out_member_id="18"
      status="Pending" 
      return="classnotes/thankyou"
      rules:title="required"
      rules:email_address="required|valid_email"
      rules:email_verify="required|matches[email_address]"
      rules:class_note="require" 
      }
    
    
    {if field_errors:count}
    <div class="classnote-error">
     <ul>
      {field_errors}<li><strong>Error:</strong>{error}</li>{/field_errors}</li>
      </ul>
    </div>
    {/if}
    
      <label for="name">Name *</label>
    
      <input name="title" type="text" value="" id="name" size="50" /></p>
      <input name="first_name" type="hidden" value="" />
      <input name="last_name" type="hidden" value="" />
        
        <label for="Email Address">Email Address *</label>
    
        <input name="email_address" type="text" value="" id="email_address" size="47" /></p>
    
                    <label for="email_verify">Verify Email Address *</label>
    
                    <input name="email_verify" type="text" value="" id="email_verify" size="47" /></p>
                    
                    <label for="school_and_year">Graduation School & Year (ex. College 2004) *</label>
    
                    
                    <input type="hidden" name="school_year[row_order][]" value="row_new_0" />
                    <select name="school_year[row_new_0][col_id_28]">
                            <option value="">Choose School</option>
                            <option value="Arch">Architecture</option>
                            <option value="Batten">Batten</option>
                            <option value="Col">College of Arts & Sciences</option>
                            <option value="Com">Commerce</option>
                            <option value="Darden">Darden School of Business</option>
                            <option value="Educ">Education (Curry)</option>
                            <option value="Engr">Engineering</option>
                            <option value="Grad">Graduate School of Arts & Sciences</option>
                            <option value="Law">Law School</option>
                            <option value="Med">Medical School</option>
                            <option value="Nurs">Nursing</option>
                            <option value="Res">Medical School Residency</option>
                            <option value="SCPS">School of Continuing & Professional Studies</option>
                        </select>
    
                        {custom_fields}
                        {if relationship}
                        <select id="graduation_year" name="graduation_year">
                            {options}
                            <option value="{option_value}"{selected}>{option_name}</option>
                            {/options}
                        </select>
                        {/if}
                        {/custom_fields}
                    
    
                    <input type="hidden" id="first_year" name="school_year[row_new_0][col_id_29]" value="--YEAR SELECTED ABOVE--">
    
                    
                    <input type="hidden" name="school_year[row_order][]" value="row_new_1" />
                    <select name="school_year[row_new_1][col_id_28]">
                            <option value="">Choose School</option>
                            <option value="Arch">Architecture</option>
                            <option value="Batten">Batten</option>
                            <option value="Col">College of Arts & Sciences</option>
                            <option value="Com">Commerce</option>
                            <option value="Darden">Darden School of Business</option>
                            <option value="Educ">Education (Curry)</option>
                            <option value="Engr">Engineering</option>
                            <option value="Grad">Graduate School of Arts & Sciences</option>
                            <option value="Law">Law School</option>
                            <option value="Med">Medical School</option>
                            <option value="Nurs">Nursing</option>
                            <option value="Res">Medical School Residency</option>
                            <option value="SCPS">School of Continuing & Professional Studies</option>
                        </select>
    
                        <select name="school_year[row_new_1][col_id_29]">
                          <option value="">Year</option>
                          <option value="2014">2014</option>
                          <option value="2013">2013</option>
                          <option value="2012">2012</option>
                          <option value="2011">2011</option>
                          <option value="2010">2010</option>
                          <option value="2009">2009</option>
                          <option value="2008">2008</option>
                          <option value="2007">2007</option>
                          <option value="2006">2006</option>
    
                          </select>
                        

     

  • #2 / Jul 30, 2013 4:41pm

    Fred2341

    25 posts

    It helps to look further in the postings.-;)
    I found the solution in this post: http://ellislab.com/forums/viewthread/235124/
    Changing the field name into an array was the (simple) trick.

    Regards

    Fred

    Hi

    I have the same problem. Initially thought it was related to a Safecracker post to a Zoo-Visitor channel, but some testing demonstrated it occurs when the Safecracker form tries to update a channel that has a relationship field. The update is carried out, but in addition to the first error you mentioned, I get a series of similar errors, all related to file relationship/ft.relationship.php, lines 87, 115, 127.

    Looking forward to anyone having a solution.

    Regards
    Fred

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases