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.

SAFEcracker PHP Errors

September 21, 2011 7:54am

Subscribe [4]
  • #1 / Sep 21, 2011 7:54am

    Jerseyjones

    19 posts

    Okay My HTML looks good or so I believe.  it’s rather lengthy so I’ll spare everyone unless requested.

    I have an Edit Entry page that calls a channel entry and enables editing. Everything looks good and when I hit submit I get this :
    ___________
    A PHP Error was encountered

    Severity: Warning

    Message: Invalid argument supplied for foreach()

    Filename: checkboxes/ft.checkboxes.php

    Line Number: 82
    ___________
    A PHP Error was encountered

    Severity: Notice

    Message: Array to string conversion

    Filename: libraries/Functions.php

    Line Number: 1449
    ___________
    A PHP Error was encountered

    Severity: Warning

    Message: Cannot modify header information - headers already sent by (output started at /home/content/79/8296179/html/tideland/codeigniter/system/core/Exceptions.php:170)

    Filename: libraries/Functions.php

    Line Number: 393
    _______________

    I have a feeling that it’s something to do with my return=“template group/template/url_title” because any edits I made in the SAEF are being made even though I’m getting an error.

    Any information would help.
    Thanks
    oh and i’m running 2.2.2

  • #2 / Sep 21, 2011 6:26pm

    Dan Decker

    7338 posts

    JerseyJones,

    I’ve got an idea what we can do to solve this, but It would be helpful to get a look at your SafeCracker template code. There is some special handling required for checkboxes, but we can get you fixed up.

    Cheers,

  • #3 / Sep 22, 2011 9:16am

    Jerseyjones

    19 posts

    I have an update. I tend to work a lot faster than these forums. here is what I’ve found.

    I tested this on a different channel and it worked fine. So I looked at the differences in settings: nothing was different, Looked at the differences in html; nothing was different, looked at the differences in the field types. nothing was different EXCEPT for the instance of 2 relationship fields and some check boxes.

    I’ll try and get some HTML up here today but to be honest, I think I am experiencing (again) the dreaded relationship field issue in Safecracker: http://ellislab.com/forums/viewthread/198179/

    If my “EditEntry” omits these fields they become blank and deliver and error. It’s not easy to add them to my form, not to mention add them “hidden” since I don’t want them changed.

  • #4 / Sep 22, 2011 7:40pm

    Dan Decker

    7338 posts

    Jerseyjones,

    Have you thought about adding those relationship fields in as such:

    <input trype="hidden" name="field_name" value="{field_name}" />

    Substituting “field_name” for the actual short name of your channel field.

    Cheers,

  • #5 / Nov 29, 2011 1:38pm

    mdonohue

    19 posts

    I am getting similar errors, using more than one checkbox field on a page.  If only one is checked it works fine, but when more than one are checked it gives me the errors.  It was working okay for a few minutes than started giving errors.

    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Invalid argument supplied for foreach()
    
    Filename: checkboxes/ft.checkboxes.php
    
    Line Number: 82
    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Cannot modify header information - headers already sent by (output started at /home/---/public_html/---/codeigniter/system/core/Exceptions.php:170)
    
    Filename: libraries/Functions.php
    
    Line Number: 393
  • #6 / Nov 30, 2011 9:42am

    mdonohue

    19 posts

    Any help on this would be greatly appreciated.  Thanks!!!!

  • #7 / Nov 30, 2011 3:53pm

    Dan Decker

    7338 posts

    Hi mdonohue,

    I’m sorry you are having these errors. It would be a big help to troubleshooting if you can supply us with your template code that is being affected. Is it possible for you to post back with the code that is giving you problems? Be sure to use BBCode code tags to aid in readability.

    Thanks!

  • #8 / Nov 30, 2011 4:05pm

    mdonohue

    19 posts

    Thanks for getting back to me.  Here is the safecracker code with just the checkboxes input info.  I removed the rest of the form, bc it’s pretty long.  I’ve also included the embed template below.  The information gets posted to the DB but it throws up the errors.  Hope you can make sense of it all.  Thanks!

    {exp:safecracker
      channel="{my_channel}"
      return="{my_template_group}/saef_residents_edit/{segment_3}/ENTRY_ID" 
      safecracker_head="yes"
      use_live_url="no"
      entry_id="{segment_4}"
      url_title=""
      datepicker="no"
      }   
    
         <div id="contactform">
         <ul>
    ...
    
    <!--SKIN CARE-->
         <li>
            <label for="skin_care">Skin Care</label>
      <div class="left">
    
    
      {embed="{my_template_group}/.skin_care_checkbox" my_segment_3="{segment_3}" my_product_id="961" my_field="sc_wash_cream_8_5" {if sc_wash_cream_8_5}checked='checked="yes"'{/if}}
      {embed="{my_template_group}/.skin_care_checkbox" my_segment_3="{segment_3}" my_product_id="962" my_field="sc_wash_cream_16_9" {if sc_wash_cream_16_9}checked='checked="yes"'{/if}}
      {embed="{my_template_group}/.skin_care_checkbox" my_segment_3="{segment_3}" my_product_id="963" my_field="sc_wash_cream_33_8" {if sc_wash_cream_33_8}checked='checked="yes"'{/if}}
      {embed="{my_template_group}/.skin_care_checkbox" my_segment_3="{segment_3}" my_product_id="966" my_field="sc_body_wash" {if sc_body_wash}checked='checked="yes"'{/if}}
      {embed="{my_template_group}/.skin_care_checkbox" my_segment_3="{segment_3}" my_product_id="964" my_field="sc_ultra_wash_cloth" {if sc_ultra_wash_cloth}checked='checked="yes"'{/if}}
      {embed="{my_template_group}/.skin_care_checkbox" my_segment_3="{segment_3}" my_product_id="965" my_field="sc_classic_wash_cloth" {if sc_classic_wash_cloth}checked='checked="yes"'{/if}}
      {embed="{my_template_group}/.skin_care_checkbox" my_segment_3="{segment_3}" my_product_id="967" my_field="sc_dry_wipes_small" {if sc_dry_wipes_small}checked='checked="yes"'{/if}}
      {embed="{my_template_group}/.skin_care_checkbox" my_segment_3="{segment_3}" my_product_id="968" my_field="sc_dry_wipes_large" {if sc_dry_wipes_large}checked='checked="yes"'{/if}}
    
      </div>
          </li>
    
         <div class="bg"></div>
    
    <!--SUBMIT-->
         <li>
            <input type="submit" name="submit" value="Submit">
            </li>
         </ul>
         </div>
    
         {/exp:safecracker}

    And here is the embedded query template for the checkboxes:

    {exp:query sql="
      SELECT
            product.entry_id AS ProductNumber,
            product.title AS ProductName,
            data.field_id_44 AS ProductCategory,
            playa.parent_entry_id AS FacilityID,
            resident.rel_parent_id AS ResidentID
      FROM
            exp_channel_titles AS product
      JOIN
            exp_playa_relationships AS playa
      ON
            product.entry_id = playa.child_entry_id
      JOIN
            exp_relationships AS resident
      ON
            playa.parent_entry_id = resident.rel_child_id
      JOIN
            exp_channel_data AS data
      ON
            product.entry_id = data.entry_id
      WHERE
            playa.parent_entry_id = '{embed:my_segment_3}'
      AND
             product.entry_id = {embed:my_product_id}
      GROUP BY
             product.entry_id
      ASC
      "}
    
                 <input type="checkbox" id="{embed:my_field}" name="{embed:my_field}" value="{ProductNumber}" {embed:checked}>{ProductName}
    
      {/exp:query}
  • #9 / Dec 05, 2011 2:27pm

    Dan Decker

    7338 posts

    Hi mdonohue,

    Hmmmm, now the issue isn’t really that similar. You doing some rather interesting things here, but my suspicion is the error is the result of your values being populated from a Playa field, and then being turned *into* checkboxes. When you submit the form, SafeCracker is expecting corresponding “Checkbox” fieldtypes to be in the Channel field group for this channel. I guessing that’s not the case, since these values are being pulled from Playa data?

    Cheers!

  • #10 / Dec 05, 2011 2:41pm

    mdonohue

    19 posts

    The values are being filtered and populated from a query of the database, but the checkboxes themselves are being entered into a separate channel which has corresponding values in checkbox fieldtypes.  Is there any way to get in touch with someone who is available to discuss this issue in a more timely manner.  I know you guys are probably swamped, but I need to figure this out ASAP.  Thanks!

  • #11 / Dec 05, 2011 4:34pm

    Dan Decker

    7338 posts

    Hi mdonohue,

    We do apologize for the delay in response times. Currently, we only offer support via the forums.

    I have an edit I would like you to add to your embed code. If you append the name for the checkbox with brackets [], you should alleviate the errors. I’ve made the edit below:

    <input type="checkbox" id="{embed:my_field}" name="{embed:my_field}[]" value="{ProductNumber}" {embed:checked}>{ProductName}

    Do let me know if that clears things up for you.

  • #12 / Dec 05, 2011 5:02pm

    mdonohue

    19 posts

    Hi Dan,

    Thank you for the quick response.  I know you guys are busy.  I added the [] brackets and still getting the same errors. :(

  • #13 / Dec 05, 2011 7:58pm

    Kevin Smith

    4784 posts

    Hi mdonohue,

    Unfortunately, we’re not set up to help troubleshoot issues that stem from third-party add-ons or custom queries in the Query module. I would recommend working with the developers of the add-ons in question here to see if you can arrive at a solution!

  • #14 / Dec 06, 2011 8:12am

    mdonohue

    19 posts

    I recreated the page simply using the natve ee checkboxes in the safecracker form with no query and no third party plugins and I am getting the same errors. Please respond as soon as possible. Thanks.

  • #15 / Dec 07, 2011 3:53pm

    Dan Decker

    7338 posts

    Hi mdonohue,

    Since you have whittled this down to native ExpressionEngine, did you make sure to use the [] on your standard checkboxes as well? Can you post your simplified code so that we can replicate?

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

ExpressionEngine News!

#eecms, #events, #releases