symfony2admingenerator / AvocodeFormExtensionsBundle

(old-legacy) Symfony2 form extensions for Admingenerator project (also working standalone!)
Other
48 stars 31 forks source link

Query Builder on collectionUploadForm is possible ? #171

Closed atrimech closed 8 years ago

atrimech commented 8 years ago

Hi all,

Here is my logs queries dataBase for FormType "afe_collection_upload", capture d ecran 2015-12-22 a 22 23 31

Can i apply an orderBy to view my pictures by order ? If that possible, how can i inject a queryBuilder ?

bobvandevijver commented 8 years ago

You should be able to add a query_builder to the options as usual with an form field. May I notice that you are using our old-legacy formextensions bundle? Please take a look at https://github.com/symfony2admingenerator/FormExtensionsBundle on how to update.

atrimech commented 8 years ago

Hi @bobvandevijver,

I've try to add this code under options array() :

'query_builder' => function($er) {
  return $er->createQueryBuilder('c')
  ->orderBy('c.position', 'ASC');
},

This is the error:

An exception has been thrown during the rendering of a template ("The option "query_builder" does not exist. Known options are: "action", "allow_extra_fields", "apply_filter", "attr", "auto_initialize", "autocomplete", "block_name", "by_reference", "cascade_validation", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_provider", "csrf_token_id", "csrf_token_manager", "data", "data_class", "data_extraction_method", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "filter_condition_builder", "help", "inherit_data", "intention", "invalid_message", "invalid_message_parameters", "label", "label_attr", "label_format", "mapped", "max_length", "method", "novalidate", "pattern", "post_max_size_message", "property_path", "read_only", "required", "translation_domain", "trim", "validation_groups", "virtual".")

Yes i'm using the old-legacy formextensions.

bobvandevijver commented 8 years ago

Hmm, in that case I'm not sure if it is possible without any custom modifications. Could you post the complete field definition?

Did you try to enable the sortable option (docs)?