Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Missing argument 1 for Ruian\UploadifyBundle\Model\Resource::__construct() #13

Open
dominikriedel opened this issue Aug 13, 2012 · 1 comment

Comments

@dominikriedel
Copy link

Hey,

I just tried to implement the RuianUploadifyBundle into my project but ran into some problems after sending the form. Upload itself is running fine and the file is uploaded to the set directory. But when i hit the submit button and the form is send to the "new" action it runs into an exception.

"Warning: Missing argument 1 for Ruian\UploadifyBundle\Model\Resource::__construct(), called in /Applications/MAMP/htdocs/Lauschtour/vendor/symfony/src/Symfony/Component/Form/Extension/Core/Type/FieldType.php on line 142 and defined in /Applications/MAMP/htdocs/Lauschtour/vendor/bundles/Ruian/UploadifyBundle/Model/Resource.php line 19"

The Form is send with the following request:
Form ->bind (array('baseData' => array('title' => 'test', 'shortDescription' => 'test', 'longDescription' => 'test', 'language' => '4'), '_token' => '6015ad221b39db0c355928d6236cd2b254e96831', 'file' => '/uploads/files/dda8271fcb3bd266a5f1cf18fa936505495c543d.png', 'picture_uploadify' => null))

Here is my "new" action:
public function editCategoryAssetAction($categoryId, $assetTypeId, $assetId)
{

    if ($assetId)
    {           
        $asset    = $this->getDoctrine()->getRepository('LauschtourMainBundle:Asset')->find($assetId);
    }
    else
    {
        $assetType  = $this->getDoctrine()->getRepository('LauschtourMainBundle:AssetType')->find($assetTypeId);
        $asset          = new Asset();
        $asset->setCategory($category);
        $asset->setAssetType($assetType);
    }

    if ($asset)
    {
        $form = $this->createForm(new EditAssetType($category->getMuseum()), $asset);

        if ($this->getRequest()->getMethod() == 'POST')
        {
            // bind form data tu user
            $form->bindRequest($this->getRequest());

            if ($form->isValid())
            {
                // update user
                $asset->save($this->getDoctrine());

                // send back to blank page

                return $this->redirect($this->generateUrl('manage_category_asset_edit', array('categoryId' => $categoryId, 'assetTypeId' => $assetTypeId)));
            }
        }
    }

    return $this->render('LauschtourFrontendBundle:Asset:editCategoryAsset.html.twig',array(
                                                                'category' => $category,
                                                                'assetTypeId' => $assetTypeId,
                                                                'asset' => $asset,
                                                    'form' => $form->createView(),
                                                                'referer' => $this->getRequest()->headers->get('referer'),
                                                                'success' => $this->getRequest()->get('success')));
}

Form Builder:
public function buildForm(FormBuilder $builder, array $options)
{
$museum = $this->museum;

    $builder->add('fileUrl', 'hidden');     
    $builder->add('picture_uploadify', 'uploadify_resource', array(
                                                                                                 'data' => array(
                                                                                                 'folder'  => '/uploads/files/',
                                                                                                 'preview' => 'picture_preview',
                                                                                                 'path'    => 'manage_category_asset_upload',
                                                                                                 'copy'    => $this->getName() . '_' . 'fileUrl'),
                                                                                                    'property_path' => false));
    $builder->add('baseData', new EditExtendedBaseDataType($museum));
}

Does someone have an idea?

@y1o1
Copy link

y1o1 commented Sep 5, 2012

Guess DataTransformer make this help.
c below
http://symfony.com/doc/master/cookbook/form/data_transformers.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants