symfony-cmf / core-bundle

Provides some basic helpers for rendering content documents
https://cmf.symfony.com
25 stars 33 forks source link

limit fields that are shown when embedding editing #81

Open dbu opened 11 years ago

dbu commented 11 years ago

this looks pretty bad (the current sandbox is still the same): http://cmf.liip.ch/de/admin/bundle/content/multilangstaticcontent/cms/content/demo/edit

is there a way we can not have the admin extension trigger when embedding? i guess that is up to the extension itself to figure it out - should we adjust it? i guess we should also hide the name as its not editable anyways.

according to thomas rabaix, the proper way to know if an admin is embedded is to check getParentFieldDescription for null. if i add this to the publish workflow extensions, it gets a lot better:

    if (null !== $formMapper->getAdmin()->getParentFieldDescription()) {
        return;
    }

shall we do that? do we have to make this configurable?

Another option is to have a less compact view ith sonata_type_collection disable the two lines

                    'edit' => 'inline',
                    'inline' => 'table',

which makes the items show as in the stand alone editing with one row per field. that is more usable then what we end up here. however, the layout then still could use a lot of tweaking.

dantleech commented 11 years ago

What if one of the extension form fields is required in the model?

dantleech commented 11 years ago

Maybe the best would be to provide a specific form builder for the embeded form that will be used in preference if it exists.

protected function confirgureEmbeddedFormFields(FormMapper $formMapper)
{
...
}
dbu commented 11 years ago

What if one of the extension form fields is required in the model?

this could be a problem when creating new items, indeed. editing existing documents is ok, you just can't change those fields then which is fine. in that case, we could provide defaults in the alterNewInstance but this gets quite hairy.

dbu commented 11 years ago

that would add yet another method to admin and admin extensions, not sure if thomas would be happy about that. i think a method isEmbeddedAdmin instead of the unobvious check for the parent name should be clean enough. but that is a general sonata topic out of scope for this issue.

sjopet commented 11 years ago
        $adminAttributes = $formMapper->getFormBuilder()->getAttribute('sonata_admin');
        $editInline = isset($adminAttributes['edit']) && $adminAttributes['edit'] == 'inline';

That's a way to check if inline editing is enabled maybe not entirely relevant for this issue though. maybe you should add the required fields always and some optional fields only when it's not an embedded form. Is it likely people are going to add pwf stuff on the menu item in an embedded form?.

dbu commented 11 years ago

@sjopet the problem is that if you enable pwf by interface, it will always trigger, also on embedded. in this case it does not matter how we attach the pwf, as the same admin is used to embed and to show menu entries stand alone.

sjopet commented 11 years ago

@dbu but you could still differentiate between when an admin is embedded or not and adjust the number of fields that are displayed.

rande commented 11 years ago

I don't get the issue here, can you be more specific ?

@dbu is right about the workflow. The extension has to figure if the current admin is embed or not.

dbu commented 11 years ago

@rande when editing embedded menu items with https://github.com/symfony-cmf/MenuBundle/blob/master/Admin/Extension/MenuNodeReferrersExtension.php (edit inline, table) and having other extensions activated on the MenuAdmin, the table rows get awfully squeezed together. you can look at http://cmf.liip.ch/de/admin/bundle/content/multilangstaticcontent/cms/content/demo/edit (login is admin/admin) to see what happens.

we try to figure out what would be the right thing to do

dbu commented 11 years ago

@rande is there a way to control the layout of an embedded admin? can it be multiline? or have some sort of horizontal tabs?