Sonataadminbundle: Autocomplete error with the basic setup (ManyToOne): Notice: Undefined index: read_only

Created on 22 Mar 2016  Â·  22Comments  Â·  Source: sonata-project/SonataAdminBundle

I just setup the basic configuration like show in the documentation in order to make one form field autocomoplete (ManyToOne relationship) but I still get the following error: Notice: Undefined index: read_only.

/** * @param FormMapper $formMapper */ protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('figureValue') ->add('wordValue') ->add('pollingStation', 'sonata_type_model_autocomplete', array('property' => 'name')) ->add('prParty') ; }

/** * @ORM\ManyToOne(targetEntity="myEntity", inversedBy="prVoteCasts") * @ORM\JoinColumn(nullable=false) */ private $pollingStation;

Most helpful comment

All 22 comments

Can you provide us with a stack trace?

Can you provide us with a stack trace?

Sorrry I don't understand but following is my composer.json: (Notice that I'm using Symfony 3.0.3)

{ "name": "root/vtally", "license": "proprietary", "type": "project", "autoload": { "psr-4": { "": "src/" }, "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "require": { "php": ">=5.5.9", "symfony/symfony": "3.0.*", "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6", "doctrine/doctrine-cache-bundle": "^1.2", "symfony/swiftmailer-bundle": "^2.3", "symfony/monolog-bundle": "^2.8", "sensio/distribution-bundle": "^5.0", "sensio/framework-extra-bundle": "^3.0.2", "incenteev/composer-parameter-handler": "^2.0", "friendsofsymfony/user-bundle": "~2.0@dev", "sonata-project/admin-bundle": "dev-master", "sonata-project/doctrine-orm-admin-bundle": "dev-master", "sonata-project/easy-extends-bundle": "^2.1", "sonata-project/user-bundle": "^2.2", "friendsofsymfony/rest-bundle": "^1.7" }, "require-dev": { "sensio/generator-bundle": "^3.0", "symfony/phpunit-bridge": "^3.0", "doctrine/doctrine-fixtures-bundle": "^2.3", "hautelook/alice-bundle": "^1.2", "doctrine/data-fixtures": "^1.1" }, "scripts": { "post-install-cmd": [ "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" ], "post-update-cmd": [ "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" ] }, "config": { "platform": { "php": "5.5.9" } }, "extra": { "symfony-app-dir": "app", "symfony-bin-dir": "bin", "symfony-var-dir": "var", "symfony-web-dir": "web", "symfony-tests-dir": "tests", "symfony-assets-install": "relative", "incenteev-parameters": { "file": "app/config/parameters.yml" } } }

A stack trace would be more helpful

Sorry ! that is it: (the framework highlight the line 4 from up to down)

$builder->setAttribute('minimum_input_length', $options['minimum_input_length']); $builder->setAttribute('items_per_page', $options['items_per_page']); $builder->setAttribute('req_param_name_page_number', $options['req_param_name_page_number']); $builder->setAttribute('disabled', $options['disabled'] || $options['read_only']); $builder->setAttribute('to_string_callback', $options['to_string_callback']); if ($options['multiple']) {

@Saint-Cyr To find the stack trace:
At the bottom of Symfony's error page, there's a section called «Stack Trace (Plain Text)» with a blue "+" icon. Click on this icon and copy what's in there:

stack-trace

Then paste it in a Gist and put the link here.
If you want people to understand your issue correctly, you should also make separate gists with your entities & admin classes (not all of them, just the relevant ones). Please make sure that they are highlighted properly.
.
Thanks.

@ju1ius thanks for doing what I did not have the strength and patience to do.

@greg0ire You're welcome!
I think we really need this.
As well as somebody who could at least label issues.

Well one more time I apologize for I didn't understand how to make it easy so fast. Finally I hope you can see it now:
https://gist.github.com/Saint-Cyr/015b98e359c6da90aabc

clicking on your link gives a 404

Ok so that's only one line of the stack trace I think. Can you give us the full stack trace ?

I'm still looking better way to publish it like yours please but for now you can see this: https://gist.githubusercontent.com/Saint-Cyr/015b98e359c6da90aabc/raw/6176162f129cf9769520ae10d8afc44386fcedc6/gistfile1.txt

vendor/sonata-project/admin-bundle/Form/Type/ModelAutocompleteType.php at line 44

This is just one line wrapped with context in one file. I would like all the files of the stack please.

Wait… IIRC, this was fixed and merged recently.

see #3668

Great job ! I'm doing "composer update" right now

Well?

Yes Thank you @greg0ire ! but after the update I realize 2 others bugs :
1 - When click on "show" action: Unable to find template "@Admin/CRUD/base_show_macro.html.twig" in SonataAdminBundle:CRUD:base_show.html.twig at line 14.

Stack trace: click here

2 - When check the roles of a user within an Admin class in order to filer the field to be displayed, it does work all the roles are still granted. As the framework (Symfony 3.0.3) does not generate error for this, I can't show any stack trace but you can see my code (from within the Admin class)

Bug 1 looks familiar, check the latest issues. I don't understand 2 , proofread your post please

See #3684

Thank you and all orther contributors of Sonata - Project for you make our job so easy ! Indeed the bug is fixed some days ago and I just update my vendor : composer update

Was this page helpful?
0 / 5 - 0 ratings