Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
6fbca6c9
Commit
6fbca6c9
authored
Feb 09, 2022
by
Julien Jorry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DocumentAdmin : add edit, show + url of documents
parent
bbd005c8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
DocumentAdmin.php
src/Admin/DocumentAdmin.php
+22
-0
url_document.html.twig
...bundles/SonataAdminBundle/Document/url_document.html.twig
+8
-0
No files found.
src/Admin/DocumentAdmin.php
View file @
6fbca6c9
...
@@ -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'
])
;
;
}
}
}
}
templates/themes/kohinos/bundles/SonataAdminBundle/Document/url_document.html.twig
0 → 100644
View file @
6fbca6c9
{%
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment