upgraded EE to 2.1.3 and getting class error
Posted: 12 February 2011 04:24 AM   [ Ignore ]
Wallflower
Rank
Total Posts:  6
Joined  2010-09-14

I just upgraded EE to 2.1.3 and got an error when I went to the form page:


Fatal error: Class ‘Safecracker’ not found in /system/expressionengine/libraries/Template.php on line 1330

any ideas/help??

Profile
 
 
Posted: 12 February 2011 04:44 AM   [ Ignore ]   [ # 1 ]
Wallflower
Rank
Total Posts:  6
Joined  2010-09-14

Ok I downloaded what might be the latest version of Safecracker - 1.0.3.

Now I’m getting PHP error:


A PHP Error was encountered
Severity: Warning
Message: in_array() [function.in-array]: Wrong datatype for second argument
Filename: libraries/safecracker_lib.php
Line Number: 761

Profile
 
 
Posted: 12 February 2011 04:46 AM   [ Ignore ]   [ # 2 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

You may want to check that the module is installed properly. Perhaps turn the module off and on (make sure to note your settings first. )

I’ve looked at the code mentioned above.. and basically it’s an instruction to call SafeCracker… and can’t find it.

Can you show me the template code from the page you’re having troubles with? Also… was this working before the upgrade? Lastly… have you also upgraded SafeCracker?

 Signature 
Profile
 
 
Posted: 12 February 2011 04:46 AM   [ Ignore ]   [ # 3 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

Whoops. Crossposted with you. I’m checking your other error now.

 Signature 
Profile
 
 
Posted: 12 February 2011 04:53 AM   [ Ignore ]   [ # 4 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

Hm… I looked at the code, and nothing *looks* suspicious. So… can you show me the template code from the page you’re having troubles with?

 Signature 
Profile
 
 
Posted: 12 February 2011 06:24 AM   [ Ignore ]   [ # 5 ]
Wallflower
Rank
Total Posts:  6
Joined  2010-09-14

OK!

I have found the issue but not a solution.

EE2 doesn’t have any good solution for SAEF add/edit forms so what I did is create a form that had an if statement like so:


{exp:channel:entries channel="staff_member" author_id="CURRENT_USER" }
  {if no_results}
      {exp:safecracker channel="staff_member" entry_id="" author_id="CURRENT_USER" form_class="myform" }
  {/if}
  {if count==1}
      {exp:safecracker channel="staff_member" entry_id="{entry_id}”  author_id=“CURRENT_USER” form_class=“myform”  }
  {/if}
{/exp:channel:entries}


Basically if there you already have a staff member (count==1) listing the the safecracker call will use that, if no entry (no_results) it will be an add new.

Anyway - that’s what’s breaking it. It’s going to be a fair bit of changes to split them into separate add and edit forms…

Profile
 
 
Posted: 12 February 2011 06:20 PM   [ Ignore ]   [ # 6 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

You don’t have any closing tags for the safecracker tags before the channel entries tag closes.

 Signature 
Profile
 
 
Posted: 14 February 2011 12:29 AM   [ Ignore ]   [ # 7 ]
Wallflower
Rank
Total Posts:  6
Joined  2010-09-14

I did that on purpose.  The rest of the safecracker form code is below the code.

Basically the logic is that if the user has an entry in existance it will be an “edit” form. If they don’t have an entry it’s an “add.” This is because they are allowed only 1 entry in this channel.

I tried putting all of the safecracker code within each if statment but it doesn’t like that at all.

What I have now that works (but not how I want) is this:

{exp:safecracker channel="staff_memberâ?  entry_id="{segment_3}"  author_only="yes" author_id="CURRENT_USER" form_class="myform"   } 

So if there is an entry id it’s an edit form and none it’s an add. I have the links set up like so:
     

{exp:channel:entries channel="staff_member" author_id="CURRENT_USER"  dynamic="off"}
        
<a href="{path=directory/listing_addedit}/{entry_id}">Edit Staff Listing</a><br />
        
{if no_results}<a href="{path=directory/listing_addedit}">Add Staff Listing</a><br />{/if}
        {
/exp:channel:entries} 

The problem is that if a user ever removes the entry ID from the URL they will be able to add additional listings.

I can’t think of any way to test if they have an entry already and make it an edit form. Have any safecracker code w/in a channel entries call seems to break it complete.

Profile