If I use a #managed_file element in a custom bean, I get the following error when trying to upload a file (in an alert):
An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/fid/form-aS7Vo5fCjL72mNjxW78cd8Fe0yvVUw26HqgxJGUrZk0
StatusText: n/a
ResponseText:
( ! ) Fatal error: Bean::getForm() [bean.getform]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "featured_video" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /SITEROOT/sites/all/modules/contrib/bean/includes/bean.core.inc on line 188
Based on the message, I think the #managed_file doesn't have enough information about the custom bean's form to rebuild it correctly. The attached patch fully loads the custom bean's class before returning the form. Is that the best method?
Comments
Comment #1
avr commentedUpdated patch - uses the built in
setPlugin().Comment #2
indytechcook commentedIs this on new entities? because that method is called with in bean_load_multiple. I've been wanted to rework those loading method for a while. Try this patch
Comment #3
indytechcook commentedChange status to revew
Comment #4
avr commentedRe: new entities - not sure if you mean the actual bean I was editing or "Entity API" module.
Previously, I was testing as I edited an existing bean and was using an older version of Entity API (Beta10).
I've updated to the latest Entity API and I'm getting a similar error as before (on both new and existing beans). It's now moved to the
setFields()- here's the full error (including stack trace):Thanks.
Comment #5
indytechcook commentedOk, try this patch. It reworks the loading and wakeup of the entity along with loading the plugin at the controller level so we know that all of the PDO issues are out of way.
Comment #6
avr commentedFor me, this patch fixed the initial issue of file uploads in custom beans.
Hopefully the architectural changes were beneficial, too. Thanks!
Comment #7
indytechcook commentedThanks. Changing status to queue it up for commit.
Comment #8
indytechcook commentedCommitted
http://drupal.org/commitlog/commit/22232/a6284086c86b233746402aa4e9301fc...