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.

Category Entries not Posting using Safecracker

February 28, 2011 2:37am

Subscribe [3]
  • #1 / Feb 28, 2011 2:37am

    a.otto

    3 posts

    I am very new to Expression Engine. I am trying to create a form where users can post an entry into a channel. The entry consists of 11 fields.  When I fill out the form I have created, all 11 fields get the entries I submit. However, there are two problems. First, after I click the submit button, I get an error message reading: 

    Fatal error: Unsupported operand types in /home/content/25/6865825/html/{../mongoinco/expressionengine/libraries/api/Api_channel_entries.php on line 1828

    Second, despite the message above, all of the field data entered still makes it to the fields, except the categories entry. The categories are basically location info. State and city. A state is the parent category with a city being the child. I am asking the user to select a city thereby also selecting the state. Below is my code. Am I missing a CP setting or not coding correctly? Thanks for the help.

    {exp:safecracker channel="listings" return="thankyou" status="pending"}
    
        <input type="hidden" name="entry_id" value="{entry_id}"/>
        <input type="hidden" name="author_id" value="{author_id}"/>
        <input type="hidden" name="url_title" value="{url_title}"/>    
        <input type="hidden" name="allow_comments" value="n"/>
                              
    <ul>
        <li class="field_divider">
                            
                            <label class="description" for="title">
                            <span class="required">*  </span>Organization Name</label>
                            <div>
                        <input class="text_long" type="text" name="title" id="title" value="{title}"/> 
                            </div> 
        </li>        
                
        {custom_fields}    
        {if field_name == "contact_name_first"}            
        <li class="field_divider">
            <label class="description"><span class="required">*  </span>Primary Contact Name</label>
            <input class="name" type="text" dir="{text_direction}" id="{field_id}" name="{field_name}" value="{field_data}" maxlength="{maxlength}"/>{/if}
    
        {if field_name == "contact_name_last"}
        <input class="name" type="text" dir="{text_direction}" id="{field_id}" name="{field_name}" value="{field_data}" maxlength="{maxlength}"/>
        
         <div>
         <label id="small_text_first" for="contact_name_first">First Name</label>
         <label id="small_text_last" for="contact_name_last">Last Name</label>
         </div>
                            
         </li>
         {/if}
         {if field_name == "organization_email"}
         <li class="field_divider">
         <label class="description" for="organization_email"><span class="required">*  </span>Contact E-mail</label>
         <input class="text_long" type="text"  dir="{text_direction}" id="{field_id}" name="{field_name}" value="{field_data}" maxlength="{maxlength}"/> 
         </li>
         {/if}
         {if field_name == "organization_website"}
         <li class="field_divider">
         <label class="description" for="organization_website">Website </label>
         <div>
         <input class="text_long" type="text" dir="{text_direction}" id="{field_id}" name="{field_name}" value="http://{field_data}" maxlength="{maxlength}"/> 
         </div>
         </li>
         <li class="field_divider">
         <div id="opt_groups">                
         <div id="opt_group_wrap_state">
         {category_menu} <label class="description" for="categories">City/Area</label> <select name="category[]" id="categories" size="4" multiple="multiple"> {select_options} </select> {/category_menu} 
         </div>
         </div>
         </li>
         {/if}
         {if field_name == "organization_address"}
         <li class="field_divider">
         <div>
         <label class="description" for="organization_address">Address</label></div>
         <input class="text_long" type="text" dir="{text_direction}" id="{field_id}" name="{field_name}" value="{field_data}" maxlength="{maxlength}">
         <div class="address_space">
         <label class="small_text" id="street">Street</label>
         </div>
         </li>
         {/if}
         {if field_name == "organization_phone"}
         <li class="field_divider">                        
         <label class="description" for="organization_phone"><span class="required">*  </span>Phone </label>
         <div>
         <label class="phone_number_text"> Example: (123) 456-7890</label>
         </div>
         <input class="text_long" type="text" dir="{text_direction}" id="{field_id}" name="{field_name}" value="{field_data}" maxlength="{maxlength}"/>
          </li>
          {/if}
          {if field_name == "organization_zipcode"}
          <li class="field_divider">        
          <label class="description" for="organization_zipcode"><span class="required">*  </span>Zipcode </label>
          <input class="text_medium" type="text" dir="{text_direction}" id="{field_id}" name="{field_name}" value="{field_data}" maxlength="{maxlength}"/>    
          </li>
          {/if}
          {if field_name == "organization_services"}
          <li class="field_divider">
          <label class="description" for="organization_services"><span class="required">*  </span>Services Offered </label>
          <textarea class="textarea_large" id="{field_id}" name="{field_name}" dir="{text_direction}" rows="{rows}">{field_data}</textarea> 
          </li>
          {/if}
          {if safecracker_file} {display_field} {/if}
          {/custom_fields}    
          <li class="buttons">
          <input id="save_form" class="button">
          </li>
          </ul>
    {/exp:safecracker}
  • #2 / Feb 28, 2011 10:00am

    Sue Crocker

    26054 posts

    Hi, a.otto.

    Can you gives us a bit more information -

    Can you tell us which version/build of EE2.x you’re using? See EEWiki:// HowTo Determine My EE Version

    Which build/version of SafeCracker?

  • #3 / Feb 28, 2011 10:32am

    a.otto

    3 posts

    Hey Sue,

    I am using Expression Engine v 2.1.3 and Safecracker v 2.0.0.

  • #4 / Feb 28, 2011 2:17pm

    a.otto

    3 posts

    Sue,

    I appologize. I haven’t given you all the info you need.  My version of Expression Engine is 2.1.3 and the build is 20101220.
    Also I am using SafeCracker v. 2.0.0 build: 20110224. 

    Hope this clarifies things.

  • #5 / Mar 01, 2011 3:47am

    John Henry Donovan

    12339 posts

    a.otto,

    Can you for now try moving your categories menu outside of the {custom_fields} pair?

  • #6 / Mar 01, 2011 4:25am

    a.otto

    3 posts

    Hey John,

    I had tried that before and just tried it again hoping it might work this time after getting tech support’s blessing. But no such luck.

    Same error message after I click submit.

    Fatal error: Unsupported operand types in /home/content/25/6865825/html/{../mongoinco/expressionengine/libraries/api/Api_channel_entries.php on line 1828

    And when I look in the control panel all of the data is making it into the channel fields except for the categories. The boxes are not ticked and it is impossible to post the information anywhere based on the category it should have. In other words, I tried to post the info thinking the category might have been successfully assigned even if it did not display so in the control panel.

  • #7 / Mar 01, 2011 7:12pm

    Sue Crocker

    26054 posts

    Hi, a.otto. I built a very rudimentary SafeCracker form, and placed my code like this:

    <link href="{path=css/_ee_saef_css}" type="text/css" rel="stylesheet" media="screen" />
    {exp:safecracker channel="test" return="test/sc/ENTRY_ID" entry_id="{segment_3}"}
    
        <label for="title">Title</label>
    
        <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100">
            
    
        <label for="url_title">URL Title</label>
    
        <input type="text" name="url_title" id="url_title" value="{url_title}" maxlength="75" size="50" />
            
    
    {custom_fields}
    <label for="{field_name}">{if required}* {/if}{field_label}</label> 
    {field_instructions}
     {formatting_buttons}
    {if textarea} <textarea id="{field_name}" name="{field_name}" dir="{text_direction}" rows="{rows}">{field_data}</textarea> {/if}
    {if date} <input type="text" id="{field_name}" name="{field_name}" value="{field_data}" size="50" /> {/if}
    {if file} 
    {display_field} 
    {/if} 
    {if safecracker_file} 
    {display_field} 
    {/if}
    {/custom_fields}
    
    
    
    
        {status_menu}
            <label for="status">Status</label>
            <select name="status" id="status">
    
            {select_options}
            </select>
        {/status_menu}
    
        <hr>
            <label for="entry_date">Date</label>
    
        <input type="text" name="entry_date" id="entry_date" value="{entry_date}" maxlength="23" size="25" />
            
    
        <label for="expiration_date">Expiration Date</label>
    
        <input type="text" name="expiration_date" id="expiration_date" value="{expiration_date}" maxlength="23" size="25" />
            
    
        <label for="comment_expiration_date">Comment Expiration Date</label>
    
        <input type="text" name="comment_expiration_date" id="comment_expiration_date" value="{comment_expiration_date}" maxlength="23" size="25" />
            
    
        
    
        <label class="checkbox"><input type="checkbox" name="allow_comments" value="y" {allow_comments} /> Allow Comments</label>
    
    
        {category_menu}
            <label for="categories">Categories</label>
            <select name="category[]" id="categories" size="4" multiple="multiple">
    
            {select_options}
            </select>
        {/category_menu}
        
        {if captcha}
            <label for="captcha">Please enter the word you see in the image below:</label
            {captcha}
    
            <input type="text" name="captcha" value="{captcha_word}" maxlength="20" />
        {/if}
    
        <input type="submit" name="submit" value="Submit" />
    
    {/exp:safecracker}

    If you try something similar, does that work?

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

ExpressionEngine News!

#eecms, #events, #releases