10390 Posts in 2201 Topics by 1712 members
| Go to End | Next > | |
| Author | Topic: | 2101 Views |
-
Re: SWFUpload Issue

16 March 2010 at 5:22am
You don't need a handleswfupload() function. It should fall back on SWFUploadControls by default.
The way SWFUpload is configured is built totally wrong. It bootstraps all the javascript on construct instead of on FieldHolder(), which makes configuring it a pain. Just make sure you do all your SWFUploadConfig assignments before the field is constructed. Lame, I know.
-
Re: SWFUpload Issue

16 March 2010 at 7:19am
Yeah I figured that, but it's still not working correctly. Here's my form constructor:
class MessageForm extends Form
{
function __construct($controller, $name, $id = 0)
{
SWFUploadConfig::addFileTypes(array(
'pdf', 'doc', 'jpg', 'png'
));SWFUploadControls::$file_class = "MessageFile";
SWFUploadConfig::set_default_upload_dir("ProjectUploads");
SWFUploadConfig::$debug = "true";$fields = singleton('Message')->getFrontEndFields();
$fields->push(new HiddenField('ProjectId', 'ProjectId', $id));
$fields->push(new SWFUploadField(
$name,
'Files',
'Upload Files',
array(
'file_upload_limit' => '1',
)
));$validators = new RequiredFields('Body');
$actions = new FieldSet(new FormAction('submit', 'Save Message'));
parent::__construct($controller, $name, $fields, $actions, $validators);
}
}All the configs are before the Field is pushed to the $fields collection, but it still no worky =(
-
Re: SWFUpload Issue

16 March 2010 at 7:48am
Which part doesn't work, exactly? The default upload dir? That needs to be in your _config.php, because it's not a SWFUpload setting. Make sure you've gotten rid of your handleswupload() function, too, cause that will override the functionality you're looking for.
-
Re: SWFUpload Issue

16 March 2010 at 4:27pm
Ok, now I'm totally confused. Nothing works at all. I've gone back to the beginning and started again.
I have SWFUpload out of the box, latest version.
Here's my form constructor:
function __construct($controller, $name, $id = 0)
{$fields = singleton('Message')->getFrontEndFields();
$fields->push(new HiddenField('ProjectId', 'ProjectId', $id));
$fields->push(new SWFUploadField($this, 'MessageFile', 'Upload Message Files'));$validators = new RequiredFields('Body');
$actions = new FieldSet(new FormAction('submit', 'Save Message'));
parent::__construct($controller, $name, $fields, $actions, $validators);
}This is not even saving a file. No file in the Uploads directory, no record in the database in the Files or MessageFiles tables.
I've created a class called MessageFile that has nothing in it but
class MessageFile extends File
{
static $has_one = array('Message' => 'Message');
}So if I understand correctly, this should work, but it should just save a file to uploads and do nothing with it, since I'm not setting the $file_class or handing it in my form's submit() method, right? And if I want to save a message file to the Uploads directory, I should just change $file_class at the beginning of my form's __construct method?
Sorry for all the confusion, I'm utterly vexed . . .
-
Re: SWFUpload Issue

16 March 2010 at 4:51pm
This doesn't look right:
SWFUploadField($this
The first argument of SWFUploadField is the name of the form, e.g. "UploadForm"
-
Re: SWFUpload Issue

16 March 2010 at 4:53pm
Sorry, let me rephrase that.. the first argument is the name of the function that creates the form.
-
Re: SWFUpload Issue

17 March 2010 at 12:12pm
So if you're subclassing Form, and building the form in the __construct function of your subclass, would that be "__construct"?
-
Re: SWFUpload Issue

17 March 2010 at 12:16pm
Ah, nevermind, it's the name of the form, which I am passing to the constructor in the $name variable
| 2101 Views | ||
| Go to Top | Next > |

