symfony2admingenerator/AvocodeFormExtensionsBundle

Collection_Upload and Propel

Opened this issue · 3 comments

Hello,

If there a sample code how to achieve admingenerator+AvocodeFormsExtensions+Propel (and vichuploader probably)?
A simple sample code with Gallery-Images will help very much to see how it works.

Thanks a lot.

@Crash21 i don't use propel, but:

  • AvocodeFormExtensionsBundle is ORM agnostic
  • AdmingeneratorGeneratorBundle supports Propel (for all features, as far as I'm aware)
  • unfortunately VichUploaderBundle does not support Propel according to README it does support only Doctrine ORM and ODM
  • however there is a way to use afe_single_upload and afe_collection_upload without dependencies and it has been documented here - the example is for Doctrine Entity, but the same would probably work with Propel object class:
    • implement Avocode\FormExtensionsBundle\Form\Model\UploadCollectionFileInterface
    • add getXxx and getXxxWebPath methods (where Xxx is the field name)
    • make sure instance of Symfony\Component\HttpFoundation\File\File is injected into $Xxx property (if the file is set ofcourse), an example impementation in the code I linked to above

Hmm I get

Key "id" in object with ArrayAccess of class "Symfony\Component\Form\FormView" does not exist in AvocodeFormExtensionsBundle:Form/CollectionUpload:template_download.html.twig at line 59

Any ideas how to fix it?

Hi @Crash21

This is because the AbstractType defined in your "type" option for your afe_collection_upload field doesn't contain any "id" field.

Why id? Simply because it is the default value of primary_key option from your afe_collection_upload field. Two things to fix it:

  1. add an id field to your Type
  2. change the primary_key option to the right one for you