Commit 6fbca6c9 by Julien Jorry

DocumentAdmin : add edit, show + url of documents

parent bbd005c8
...@@ -8,6 +8,7 @@ use Sonata\AdminBundle\Admin\AbstractAdmin; ...@@ -8,6 +8,7 @@ use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Form\FormMapper;
use Sonata\MediaBundle\Form\Type\MediaType; use Sonata\MediaBundle\Form\Type\MediaType;
use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
...@@ -72,6 +73,27 @@ class DocumentAdmin extends AbstractAdmin ...@@ -72,6 +73,27 @@ class DocumentAdmin extends AbstractAdmin
'label' => 'Activé', 'label' => 'Activé',
'editable' => true, 'editable' => true,
]) ])
->add('_action', null, [
'actions' => [
'show' => [],
'edit' => []
],
])
;
}
/**
* {@inheritdoc}
*/
protected function configureShowFields(ShowMapper $showMapper): void
{
$object = $showMapper->getAdmin()->getSubject();
$showMapper
->add('createdAt', null, ['label' => 'Date de création'])
->add('name', null, ['label' => 'Nom'])
->add('content', null, ['label' => 'Description'])
// ->add('media')
->add('media', null, ['label' => 'Url du media', 'template' => '@kohinos/bundles/SonataAdminBundle/Document/url_document.html.twig'])
; ;
} }
} }
{% extends '@SonataAdmin/CRUD/base_show_field.html.twig' %}
{% block field%}
{% if object.media is defined %}
<a href="{% path object.media, 'reference' %}" target="_blank">{% path object.media, 'reference' %}</a>
{% endif %}
{% endblock %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment