Giter Club home page Giter Club logo

sonataadminbundle's People

Contributors

andrewmy avatar axzx avatar bladrak avatar caponica avatar core23 avatar dbu avatar dmaicher avatar emmanuelvella avatar franmomu avatar gaelb80 avatar greg0ire avatar jordisala1991 avatar jorrit avatar kunicmarko20 avatar mweimerskirch avatar nenuial avatar oskarstark avatar phansys avatar pulzarraider avatar qsomazzi avatar rande avatar romain-geissler avatar sonataci avatar soullivaneuh avatar stof avatar taluu avatar tambait avatar tiagojsag avatar vincentlanglet avatar wouterj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonataadminbundle's Issues

sonata_type_collection and ManyToOne issue

Seems like there's an issue with the 'sonata_type_collection' type. Let's imagine the following example (this is just a fictional example, but the scenario is exactly the same as what I have in my real application). We have 3 objects:

  • Thread
  • Comment
  • User

Now we want to be able, in the Admin, to create a Thread and at the same screen, add comments to that thread. This can be accomplished by doing something like:

// ThreadAdmin.php
protected $form = array(
    'title',
    'comments' => array(
        'edit' => 'inline'
    )
);

// CommentAdmin.php
protected $form = array(
    'comment',
    'user' => array('edit'=>'list')
);

// UserAdmin.php
protected $list = array(
    'username' => array('identifier'=>true)
);

If you create a new Thread, you will be allowed to create new comments, inline, at the same screen, because it uses the 'sonata_type_collection'. Each Comment you add to the form will have a User element (ManyToOne relation), that will be rendered using a special widget where you can select a User via a lightbox.

So far so good, but there's a problem in this scenario. When you add a Comment, and then select a User and click save, it successfully save everything into the database, with all the relations. But after page reloads (or if you later go back to edit that Thread), all Comment entries will display BLANK user. If you change the user and save again, it correctly saves into the database, but again, once it reloads, it will be displayed BLANK. If you remove the 'edit'=>'list' and let it render a widget, it works fine. I tried to debug myself and I tracked the issue back to the "renderFormElement" method of SonataAdminExtension class. At line 181, it calls: return $this->output($fieldDescription, $template->render(array_merge($params, array( 'admin' => $fieldDescription->getAdmin(), 'object' => $object, 'field_description' => $fieldDescription, 'value' => $this->getValueFromFieldDescription($object, $fieldDescription, $params), 'field_element' => $children, 'base_template' => $fieldDescription->getOption('base_template', $base_template) )))); getValueFromFieldDescription in turn does: โ€ฆ $value = $fieldDescription->getValue($object); // no value defined, check if the fieldDescription point to an association // if so, create an empty object instance // fixme: not sure this is the best place to do that if (!$value && $fieldDescription->getAssociationAdmin()) { $value = $fieldDescription->getAssociationAdmin()->getNewInstance(); } return $value finally, $fieldDescription->getValue($object) will end up calling $object->getUser(). But while debugging, I noticed that $object variable actually holds a PersistentCollection object instead of a real Comment object, therefore, getUser() getter is not available and we will end up with a brand new Comment instance (with everything blank). I'm not sure if I'm at the right track, but something is not right in this scenario. Also, there's another problem (maybe related to the 1st one). Say you add two Comments to the Thread, if you set the User for the 2nd Comment and click save, any validation attached to the User entity will fail, as if it's blank.

Adding a new relation to a new relation

When adding a new relation to another new relation, it 404's on returning the new form entity to the first entity dialog. I'll attach some samples when I'm on my computer.

Admin\Pool::__construct error

Catchable fatal error: Argument 1 passed to Sonata\AdminBundle\Admin\Pool::__construct() must implement interface Symfony\Component\DependencyInjection\ContainerInterface, none given, called in SymfonyPR12/app/cache/dev/appDevDebugProjectContainer.php on line 1064 and defined in SymfonyPR12/src/Sonata/AdminBundle/Admin/Pool.php on line 26

Somthing wrong with controller

I have a bundle:

autoload:
'APM' => DIR.'/../src',

appkernel:
new APM\TestDesignBundle\APMTestDesignBundle(),

creating Admin class, and write this in config.yml:

sonata_base_application:
entities:
post:
label: Test
group: test
class: APM\TestDesignBundle\Admin\TestAdmin
entity: APM\TestDesignBundle\Entity\Test
controller: TestDesignBundle:TestAdmin

after that i see dashboard with links list/add
but have an error when click on list

generated url: .../app_dev.php/admin/apm/testdesign/test/list

error:
ERR InvalidArgumentException: Bundle "TestDesignBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() function of your AppKernel.php file? (uncaught exception)

i am trying in config.yml all combinations
controller: APM\TestDesignBundle:TestAdmin
controller: APMTestDesignBundle:TestAdmin
and so on - doesnt work.

What i miss?

Add support for sortable

Association might have an order field, for now the user need to edit the value in the embedded form

Symfony MenuBundle installation on src/Knplabs/Bundle/MenuBundle causes errors

As recommended, a MenuBunble installation, as base to Admin Bundle installation, in the directory src/Knplabs/Bundle/MenuBundle causes errors.

The first one I noted is on app/console command that finish execution with an error:
"[Exception] The autoloader expected class "Knplabs\Bundle\MenuBundle\KnplabsMenuBundle" to be defined in file "<proj_root>/app/../src/Knplabs/Bundle/MenuBundle/KnplabsMenuBundle.php". You probably have a typo in the namespace or the class name."

(<proj_root> is my project root directory)
Then, if you made all configurations recommended, the bundle does not work.

I verify that:

  1. Installing Menu Bundle in src/Knplabs/MenuBundle
  2. Changing the line app/AppKernel.php wich loads it from
    "new Knplabs\Bundle\MenuBundle\KnplabsMenuBundle(),"
    to
    "new Knplabs\MenuBundle\KnplabsMenuBundle(),"
  3. Changing the lines (31 and 32) of src/Sonata/AdminBundle/Admin/Admin.php from
    use Knplabs\Bundle\MenuBundle\Menu;
    use Knplabs\Bundle\MenuBundle\MenuItem;
    to
    use Knplabs\MenuBundle\Menu;
    use Knplabs\MenuBundle\MenuItem;
    make AdminBundle start to work.

I suggest that you make change 3. on AdminBundle code.

error in list if the target object return null

Hi ,

I am receiving this message in my list if my object doesn't have a target object set and returns a null :

Catchable fatal error: Method MyBundle\Entity\MyEntity::__toString() must return a string value in \beta1\vendor\twig\lib\Twig\Extension\Core.php on line 336

This is happening for the many-to-one or I believe for one-to-one.
BTW: I am using gedmo-doctrine-extensions -> nested trees, but I believe this has nothing to do with this.

I opened here the issue because I am not really sure where to go .
Please advise !

Thanks in advance !

many-to-one form fields dont work

I have an entity with field MailTemplate::$type. The following form definition doesn't work but injects a string into MailTemplate::setType() when saving or editing an instance:

    $choices = array();
    foreach ($mailTypes AS $mailType) {
        $choices[$mailType->getId()] = $mailType;
    }

    $form->add('type', array('label' => 'Mail-Typ', 'choices' => $choices), array('type' => 'choice'));

Adding a new relation to a new relation

When adding a new relation to another new relation, it 404's on returning the new form entity to the first entity dialog. I'll attach some samples when I'm on my computer.

Namespace of MenuBundle is different

Namespace used in AdminBundle is something like "Knplabs\Bundle...." .
And the namespace in MenuBundle is "Knplabs\MenuBundle".
This is a conflict, which is no really good.

{_locale} prefix in routes

Hi,

Using "/{_locale}/admin" as prefix, but it doesn't work : "No route found for GET /fr/admin/dashboard".

Config admin class throught yaml file

What do you think about allowing config for list, form, field trought a yaml file like symfony 1 admin generator does ?

It could help people to adapt faster to this new version.

I can have a try on this feature if you are comfortable with this idea.

MongoDB compatibility

I'm afraid that actually only ORM is supported. I'm willing to introduce support for MongoDB. If I do so, will you consider merging?

Replacing Admin class with yml config

In my humble opinion Admin classes aren't as handy as generator.yml in symfony 1.x Have you considered putting configuration to config file? In fact part of configuration is located in config.yml (class, entity, controller) so why not put fields, forms and other configs there, as well?

Many to Many error

Hi,

After defining many to many relation i get an error while trying to edit one of entity:

Warning: Invalid argument supplied for foreach() in /home/krymen/workshop/netteam3_sandbox/src/vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Form/ValueTransformer/CollectionToChoiceTransformer.php on line 78

Any ideas how to fix it?

Entity list exception

An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 24 near 'id) as cnt FROM': Error: Class Sdv\MonitoringBundle\Entity\User has no field or association named id") in SonataAdminBundle:CRUD:base_list.html.twig at line 25.

And my YAML file for this table begins with :

Sdv\MonitoringBundle\Entity\User:
type: entity
table: user
fields:
idUser:
id: true
type: bigint
column: id_user
generator:
strategy: IDENTITY
nom:
type: string
length: 255

Could you help me please ?

Route "admin_sf2mcq_core_category_create" does not exist

I'm trying to setup a basic admin but I'm stuck on that error :

An exception has been thrown during the rendering of a template ("Route "admin_sf2mcq_core_category_create" does not exist.") in SonataAdminBundle:Core:dashboard.html.twig at line 30. 

I believe I followed the tutorial carefully.

Here is my configuration

services:
   sf2mcq.core.admin.category:
      class: Sf2MCQ\CoreBundle\Admin\CategoryAdmin
      tags:
        - { name: sonata.admin, manager_type: orm, group: sonata_blog, label: category }
      arguments: [null, Sf2MCQ\CoreBundle\Entity\Category, Sf2MCQCoreBundle:CategoryAdmin]

Is is not clear to me If I have to change things in the tags field. name: foo fixes the issue but display nothing in the admin area...

Add_empty option

The add_empty possibility on relation fields disapeared, or is not working anymore. Was that intentional ?

Expose FormBuilder more

It seems the FieldMapper severly cripples the capabilities to work with the FormBuilder.

Why is this FieldDefinition stuff even needed? The Form framework has tons of extension points to define arbitrary view and form attributes through decorators and such. It seems the abstraction layer is using the "old" form API of the admin bundle and tried to wrap the new form framework in it.

RouteCollection already in use

Upon requesting any admin page, I get the following error:
Fatal error: Cannot use Symfony\Component\Routing\RouteCollection as RouteCollection because the name is already in use in /home/pascal/Projects/usmedia/UsMediaWebsite/vendor/bundles/Sonata/AdminBundle/Route/AdminPoolLoader.php on line 14

Apparently, The RouteCollection is initialized somewhere else previously.
A simple workaround is to load the Symfony\Component\Routing\RouteCollection as AdminRouteCollection (for example) and use that name instead.

Breadcrumbs aren't displayed anymore

Since the latest commits (probably Admin class refactoring), the breadcrumbs aren't displayed anymore.

I didn't have time to track down the reason why that is, maybe tomorrow if I have a moment I'll try and look into it. If it hasn't been fixed by then.

Decouple _action from $list

Currently _action reuses the $list parameter for a second purpose, which is relaly bad practice. It should be in its own $listActions = array() variable.

The CSRF token is invalid. Please try to resubmit the form

Hi ,

I am receiving this error when I am trying to do anything related to form use. I am also using a contact form and the error is not present.

I think this issue appears because there is no CSRF hidden field present in the form...!?

'orm_many_to_one' type doesnt work

It trys to access the associationadmin.generateUrl, but that doesnt exist in the view.

I dont always have an admin for the associated entity, why generate a link to "edit" it?

Additionally this is a security problem here again, why allow to add the entity if you dont even know the associated entity provides an edit facility?

Associating and Disassociating Child Elements

Hi,

I have a simple one-to-many relationship (Customer->Addresses), with no join table. Simply the address table has the foreign key 'customer_id'.

Though the tutorial example used a join table, I was able to load the form with no real problem. However the issue comes when saving or deleting an address.

When saving a new address, it will create the address in the table, but the customer_id field I noticed was not being populated.
So the the following edit screen appears with no associated addresses (though the address record is in the database).

My solution was to manually add this missing value in the 'preUpdate' function of my CustomerAdmin class:

        foreach($object->getAddresses() as $address){
            $address->setCustomer($object);
        }

The same issue came when you wanted to delete an address, ticking the box correctly removes the item from the object in memory, but when flushed .... the record still exists in the database and so appears in the edit screen.

My solution to this was to add the following code to the 'preUpdate' function:

if($object->getId()){
            $em = $this->modelManager->getEntityManager();
            $query = $em->createQuery("SELECT a FROM Customer\Address a WHERE a.customer = '".$object->getId()."'");
            foreach($query->getResult() as $address){
                if(!$object->hasAddress($address)) $em->remove($address);
            }
        }

These updates seem less of a hack as I am overriding the 'preUpdate' function for 'CustomerAdmin', but I would have assumed that such functionality ought to have been auto-magic ;) .

Is there a better way to accomplish this?

Thanks

M.

Edit entity with many-to-one marked as choice: warning

Notice: Object of class Proxies\HWSPlatformBundleEntityMailTypeProxy could not be converted to int in /home/benny/code/php/wsnetbeans/lsl-ff-db/lsl-ff-db/vendor/symfony/src/Symfony/Component/Form/Util/FormUtil.php on line 18

This happens when trying to edit an entity with a many-to-one entity marked as 'choice'

Problems with translation

Two errors are still lingering around since the change in Twigs way to handle translation :

Unexpected token. Twig was looking for the "with" or "from" keyword in SonataAdminBundle:CRUD:base_filter_field.html.twig at line 15.

Unexpected token. Twig was looking for the "with" or "from" keyword in SonataAdminBundle:CRUD:base_edit.html.twig at line 35.

Write prope jQuery plugin instead of generating

The jQuery code is auto-generated currently, but it follows patterns. Additionally there is onclick="" used instead of proper jQuery event handling. This should be cleaned up alot and injecting the relevant data into the plugin using html5 data-* properties.

Reuse of type details

Currently it seems you have to redefine the type information in both form and list instead of having a central place Admin::$types where you define all the types and then re-use their names in the list and form description.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.