17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1430 Views |
-
Custom Edit form - Fatal error: Call to a member function securityTokenEnabled() on a non-object

29 April 2008 at 10:05am
Hi All,
I created a custom edit form, whenever I try to save the changes a fatal error is displayed
"Fatal error: Call to a member function securityTokenEnabled() on a non-object ".Thanks,
Mohan -
Re: Custom Edit form - Fatal error: Call to a member function securityTokenEnabled() on a non-object

30 April 2008 at 5:21pm Last edited: 30 April 2008 5:21pm
Could you paste your code in here, or provide a link to view the code?
Or use Pastie - http://pastie.caboo.se/
Cheers,
Sean -
Re: Custom Edit form - Fatal error: Call to a member function securityTokenEnabled() on a non-object

1 May 2008 at 5:14am
Sean,
Thanks for your quick reply.
Please check the link for the code.
http://pastie.caboo.se/pastes/189380
For a particular member, the profile is getting displayed in their respective
field set. But, when I try to save the changes, I get fatal error.I once again appreciate for your quick reply.
Thanks!!
-
Re: Custom Edit form - Fatal error: Call to a member function securityTokenEnabled() on a non-object

1 May 2008 at 11:00pm Last edited: 1 May 2008 11:06pm
I would probably do checks before assuming that a certain record you're retrieving is there.
For example, you're calling $form->loadDataFrom($newappt). I do know that loadDataFrom() will probably throw an error if $newappt isn't an object, or an array.
Also, you probably need to do another check in your dosave() method. Checking if your $editappt variable has any contents after calling DataObject::get_by_id(). This means a non-object fatal error won't get shown if the ID was wrong, or there was no record found, because there's a write() method called which will ultimately fail on a non-object.
Oh, and one last thing, I would probably force an integer type on the ID after fetching it from $_GET, otherwise you might have some SQL injection possibilities arising. Just do something like $newappt = DataObject::get_one("NewAppt","`ID` = " . (int)$id).
Perhaps after these it might fix the problem. I don't want to just reply saying how you need to fix your code up, because that's not the intention, however, judging by the fact there's a non-object error, I think it may be caused by a lack of checking. But, in saying that, it could be something else completely! I'd say give it a go though, you've got nothing to lose!
Cheers,
Sean
| 1430 Views | ||
|
Page:
1
|
Go to Top |


