Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
Tourinsoft
Project
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
0
Merge Requests
0
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
Bolt Extensions
Tourinsoft
Commits
517a741d
Commit
517a741d
authored
May 11, 2018
by
Frédéric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flux form
parent
a4a35e57
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
51 deletions
+137
-51
FluxController.php
src/Controller/Backend/FluxController.php
+6
-8
FluxType.php
src/Form/FluxType.php
+48
-5
add.html.twig
templates/Backend/flux/add.html.twig
+43
-20
edit.html.twig
templates/Backend/flux/edit.html.twig
+40
-18
No files found.
src/Controller/Backend/FluxController.php
View file @
517a741d
...
...
@@ -4,8 +4,8 @@ namespace Bolt\Extension\Appolo\Tourinsoft\Controller\Backend;
use
Bolt\Application
;
use
Bolt\Controller\Backend\BackendBase
;
use
Bolt\Extension\Appolo\Tourinsoft\Form\FluxType
;
use
Bolt\Extension\Appolo\Tourinsoft\Storage\Entity\Flux
;
use
Bolt\Extension\Appolo\Tourinsoft\Storage\Repository\FluxRepository
;
use
Bolt\Extension\Appolo\Tourinsoft\Synchronisation\Synchronisation
;
use
Silex\ControllerCollection
;
use
Symfony\Component\HttpFoundation\Request
;
...
...
@@ -65,10 +65,9 @@ class FluxController extends BackendBase
* @throws \Exception
*/
public
function
add
(
Request
$request
)
{
$flux
=
$this
->
getRepository
(
Flux
::
class
)
->
findAll
();
$form
=
$this
->
createForm
(
'Bolt\Extension\Appolo\Tourinsoft\Form\FluxType'
,
new
Flux
());
$form
->
handleRequest
(
$request
);
$form
=
$this
->
createFormBuilder
(
FluxType
::
class
,
new
Flux
())
->
getForm
()
->
handleRequest
(
$request
);
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
{
...
...
@@ -81,8 +80,7 @@ class FluxController extends BackendBase
}
return
$this
->
render
(
'@tourinsoft/Backend/flux/add.html.twig'
,
[],
[
'form'
=>
$form
->
createView
(),
'flux'
=>
$flux
'form'
=>
$form
->
createView
()
]);
}
...
...
@@ -99,7 +97,7 @@ class FluxController extends BackendBase
return
$this
->
redirectToRoute
(
'tourinsoft_admin_flux_index'
);
}
$form
=
$this
->
createForm
(
'Bolt\Extension\Appolo\Tourinsoft\Form\FluxType'
,
$flux
);
$form
=
$this
->
createForm
(
FluxType
::
class
,
$flux
,
[
'edit_mode'
=>
true
]
);
$form
->
handleRequest
(
$request
);
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
...
...
src/Form/FluxType.php
View file @
517a741d
...
...
@@ -6,6 +6,7 @@ use Symfony\Component\Form\AbstractType;
use
Symfony\Component\Form\Extension\Core\Type\TextType
;
use
Symfony\Component\Form\FormBuilderInterface
;
use
Symfony\Component\OptionsResolver\OptionsResolver
;
use
Symfony\Component\Validator\Constraints\NotBlank
;
class
FluxType
extends
AbstractType
{
...
...
@@ -20,28 +21,68 @@ class FluxType extends AbstractType
TextType
::
class
,
[
'label'
=>
'Titre'
,
'required'
=>
false
'required'
=>
true
,
'attr'
=>
[
'class'
=>
'form-control'
],
'label_attr'
=>
[
'class'
=>
'main control-label col-xs-12'
],
'constraints'
=>
array
(
new
NotBlank
([
'message'
=>
'Le titre est requis.'
])
),
])
->
add
(
'code'
,
TextType
::
class
,
[
'label'
=>
'Code'
,
'required'
=>
false
'required'
=>
false
,
'attr'
=>
[
'class'
=>
'form-control'
],
'label_attr'
=>
[
'class'
=>
'main control-label col-xs-12'
]
])
->
add
(
'key'
,
TextType
::
class
,
[
'label'
=>
'Key'
,
'required'
=>
false
'required'
=>
true
,
'attr'
=>
[
'class'
=>
'form-control'
],
'label_attr'
=>
[
'class'
=>
'main control-label col-xs-12'
],
'constraints'
=>
array
(
new
NotBlank
([
'message'
=>
'La clé est requise.'
])
),
])
->
add
(
'contentType'
,
TextType
::
class
,
[
'label'
=>
'Content Type'
,
'required'
=>
false
'required'
=>
true
,
'read_only'
=>
$options
[
'edit_mode'
],
'attr'
=>
[
'class'
=>
'form-control'
],
'label_attr'
=>
[
'class'
=>
'main control-label col-xs-12'
],
'constraints'
=>
array
(
new
NotBlank
([
'message'
=>
'Le type de contenu est requis.'
])
),
])
;
}
...
...
@@ -51,7 +92,9 @@ class FluxType extends AbstractType
*/
public
function
configureOptions
(
OptionsResolver
$resolver
)
{
$resolver
->
setDefaults
([]);
$resolver
->
setDefaults
([
'edit_mode'
=>
false
]);
}
/*
...
...
templates/Backend/flux/add.html.twig
View file @
517a741d
...
...
@@ -12,25 +12,47 @@
{%
block
page_main
%}
{{
form_start
(
form
)
}}
<div
class=
"col-md-8"
>
{{
form_label
(
form.title
)
}}
{{
form_widget
(
form.title
)
}}
{{
form_errors
(
form.title
)
}}
</div>
<div
class=
"col-md-8"
>
{{
form_label
(
form.code
)
}}
{{
form_widget
(
form.code
)
}}
{{
form_errors
(
form.code
)
}}
</div>
<div
class=
"col-md-8"
>
{{
form_label
(
form.key
)
}}
{{
form_widget
(
form.key
)
}}
{{
form_errors
(
form.key
)
}}
</div>
<div
class=
"col-md-8"
>
{{
form_label
(
form.contentType
)
}}
{{
form_widget
(
form.contentType
)
}}
{{
form_errors
(
form.contentType
)
}}
<div
data-bolt-fieldset=
"text"
>
<fieldset
class=
"form-group bolt-field-text"
>
{{
form_label
(
form.title
)
}}
<div
class=
"col-xs-12"
>
{{
form_widget
(
form.title
)
}}
{{
form_errors
(
form.title
)
}}
</div>
</fieldset>
</div>
<div
data-bolt-fieldset=
"text"
>
<fieldset
class=
"form-group bolt-field-text"
>
{{
form_label
(
form.code
)
}}
<div
class=
"col-xs-12"
>
{{
form_widget
(
form.code
)
}}
{{
form_errors
(
form.code
)
}}
</div>
</fieldset>
</div>
<div
data-bolt-fieldset=
"text"
>
<fieldset
class=
"form-group bolt-field-text"
>
{{
form_label
(
form.key
)
}}
<div
class=
"col-xs-12"
>
{{
form_widget
(
form.key
)
}}
{{
form_errors
(
form.key
)
}}
</div>
</fieldset>
</div>
<div
data-bolt-fieldset=
"text"
>
<fieldset
class=
"form-group bolt-field-text"
>
{{
form_label
(
form.contentType
)
}}
<div
class=
"col-xs-12"
>
{{
form_widget
(
form.contentType
)
}}
{{
form_errors
(
form.contentType
)
}}
</div>
</fieldset>
</div>
</div>
<!-- sidebar -->
<aside
class=
"col-md-4"
>
<div
class=
"panel panel-default panel-news"
>
...
...
@@ -39,7 +61,7 @@
{{
__
(
'Actions'
)
}}
</div>
<div
class=
"panel-body"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Valider l
'ajout
</button>
<button
type=
"submit"
class=
"btn btn-primary"
>
Valider l
a modification
</button>
<br/>
<a
class=
"btn btn-default"
style=
"margin-top: 1em;"
href=
"
{{
path
(
'tourinsoft_admin_flux_index'
)
}}
"
>
<i
class=
"fa fa-undo"
aria-hidden=
"true"
></i>
{{
__
(
'Retour à la liste des flux'
)
}}
...
...
@@ -49,4 +71,4 @@
</aside>
<!-- / sidebar -->
{{
form_end
(
form
)
}}
{%
endblock
%}
{%
endblock
%}
\ No newline at end of file
templates/Backend/flux/edit.html.twig
View file @
517a741d
...
...
@@ -12,25 +12,47 @@
{%
block
page_main
%}
{{
form_start
(
form
)
}}
<div
class=
"col-md-8"
>
{{
form_label
(
form.title
)
}}
{{
form_widget
(
form.title
)
}}
{{
form_errors
(
form.title
)
}}
</div>
<div
class=
"col-md-8"
>
{{
form_label
(
form.code
)
}}
{{
form_widget
(
form.code
)
}}
{{
form_errors
(
form.code
)
}}
</div>
<div
class=
"col-md-8"
>
{{
form_label
(
form.key
)
}}
{{
form_widget
(
form.key
)
}}
{{
form_errors
(
form.key
)
}}
</div>
<div
class=
"col-md-8"
>
{{
form_label
(
form.contentType
)
}}
{{
form_widget
(
form.contentType
,
{
'attr'
:
{
'readonly'
:
'true'
}
}
)
}}
{{
form_errors
(
form.contentType
)
}}
<div
data-bolt-fieldset=
"text"
>
<fieldset
class=
"form-group bolt-field-text"
>
{{
form_label
(
form.title
)
}}
<div
class=
"col-xs-12"
>
{{
form_widget
(
form.title
)
}}
{{
form_errors
(
form.title
)
}}
</div>
</fieldset>
</div>
<div
data-bolt-fieldset=
"text"
>
<fieldset
class=
"form-group bolt-field-text"
>
{{
form_label
(
form.code
)
}}
<div
class=
"col-xs-12"
>
{{
form_widget
(
form.code
)
}}
{{
form_errors
(
form.code
)
}}
</div>
</fieldset>
</div>
<div
data-bolt-fieldset=
"text"
>
<fieldset
class=
"form-group bolt-field-text"
>
{{
form_label
(
form.key
)
}}
<div
class=
"col-xs-12"
>
{{
form_widget
(
form.key
)
}}
{{
form_errors
(
form.key
)
}}
</div>
</fieldset>
</div>
<div
data-bolt-fieldset=
"text"
>
<fieldset
class=
"form-group bolt-field-text"
>
{{
form_label
(
form.contentType
)
}}
<div
class=
"col-xs-12"
>
{{
form_widget
(
form.contentType
)
}}
{{
form_errors
(
form.contentType
)
}}
</div>
</fieldset>
</div>
</div>
<!-- sidebar -->
<aside
class=
"col-md-4"
>
<div
class=
"panel panel-default panel-news"
>
...
...
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