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
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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
Could you paste your code in here, or provide a link to view the code?
Or use Pastie - http://pastie.caboo.se/
Cheers,
Sean
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!!
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