enigmadigital / Formerly

Plugin to allow users to create custom forms within Craft CMS
MIT License
59 stars 24 forks source link

Upload field not implemented #51

Closed xtrasmal closed 9 years ago

xtrasmal commented 9 years ago

Hey hello how are you?

So what is the deal with the Assets field anyway? Can somebody please explain how or what is happening and why.

            case Formerly_QuestionType::Assets:
                $folderId = 1;
                $allowedKinds = array("excel","image","pdf","text","word");
                if (craft()->config->exists(Formerly_ConfigSettings::SettingsGroupName))
                {
                    if (array_key_exists(Formerly_ConfigSettings::UploadAssetFolderId, craft()->config->get(Formerly_ConfigSettings::SettingsGroupName)))
                    {
                        $folderId = craft()->config->get(Formerly_ConfigSettings::SettingsGroupName)[Formerly_ConfigSettings::UploadAssetFolderId];
                    }
                    if (array_key_exists(Formerly_ConfigSettings::AllowedKinds, craft()->config->get(Formerly_ConfigSettings::SettingsGroupName)))
                    {
                        $allowedKinds = craft()->config->get(Formerly_ConfigSettings::SettingsGroupName)[Formerly_ConfigSettings::AllowedKinds];
                    }
                }
                $field->type = 'Assets';
                $field->settings = array(
                    'useSingleFolder'               => '1',
                    'sources'                       => array('folder:' . $folderId),
                    'defaultUploadLocationSource'   => '1',
                    'defaultUploadLocationSubpath'  => '',
                    'singleUploadLocationSource'    => $folderId,
                    'singleUploadLocationSubpath'   => '',
                    'restrictFiles'                 => '1',
                    'allowedKinds'                  => $allowedKinds,
                    'limit'                         => '1'
                );
                break;
wiso1234 commented 9 years ago

lol I like your request - explain how or what is happening and why.

Can you describe your issue. How far along are you? Do you have an upload field on a form? Or is it that you don't know where to start?

xtrasmal commented 9 years ago

haha yea I was kinda losing it. Long day yesterday.

I've got a form with an asset field. And that's where I get stuck. What things do I need to configure?

xtrasmal commented 9 years ago

@wiso1234 Goodmorning Vietnam!!

How was your weekend?

wiso1234 commented 9 years ago

Hmm yeah you're right it doesn't work.

I remember when I wrote I was surprised I didn't need to implement the asset saving code, it just seemed to work because of the field setup. But now I can't get it to work on a new project. I'll have a bit of time tomorrow to try and get it working

xtrasmal commented 9 years ago

ok please. I need to dive in to it as well, because I've got designs for a contactform and the specifications say that I need to add an uploadfield.

wiso1234 commented 9 years ago

Ugh i worked it out after 3 hours of wading through the craft core. It wasnt working because i didn't have enctype="multipart/form-data" on my form so of course it wasnt posting the file. I added that now it works fine

See if thats your problem too On 29/10/2015 1:53 AM, "Xander Smalbil" notifications@github.com wrote:

ok please. I need to dive in to it as well, because I've got designs for a contactform and the specifications say that I need to add an uploadfield.

— Reply to this email directly or view it on GitHub https://github.com/xodigital/Formerly/issues/51#issuecomment-151870898.

wiso1234 commented 9 years ago

I've update the sample form.html to add the extra attribute

xtrasmal commented 8 years ago

Thanks it works!

xtrasmal commented 8 years ago

Oh wait one moment.