Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
potage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mathieu
potage
Commits
e8cc1338
Commit
e8cc1338
authored
Sep 18, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form commande: parcourt les légumesSorted pour hydrater le sous-formulaire
parent
d5ba27cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
62 deletions
+17
-62
src/PotageBundle/Controller/MembreController.php
src/PotageBundle/Controller/MembreController.php
+17
-11
src/PotageBundle/Resources/views/Membre/today.js
src/PotageBundle/Resources/views/Membre/today.js
+0
-51
No files found.
src/PotageBundle/Controller/MembreController.php
View file @
e8cc1338
...
...
@@ -92,20 +92,26 @@ class MembreController extends MasterController
}
/**
* Le formulaire de commande
* Le formulaire de commande, formulaire imbriqué
* qui crée une commande et des commandeLégumes
*
* @var OffreLegumes $legume
*/
$commande
=
new
Commande
(
$offre
,
$user
);
$legume
=
new
CommandeLegumes
();
//boucle//////
//$legume
//->setPrixUnitaire(2.6)
//->setUnite('botte')
//->setQuantite(3)
//->setPrix(7.8);
//////////
$commande
->
addCommandeLegumes
(
$legume
);
foreach
(
$currentOffre
[
'legumesSorted'
]
as
$legume
)
{
dump
(
$legume
->
getNom
());
$item
=
new
CommandeLegumes
();
$item
->
setPrixUnitaire
(
$legume
->
getPrixUnitaire
())
->
setUnite
(
$legume
->
getUnite
())
->
setQuantite
(
0.0
)
->
setPrix
(
0.0
)
;
$commande
->
addCommandeLegumes
(
$item
);
}
$form
=
$this
->
createForm
(
CommandeType
::
class
,
$commande
);
$form
->
handleRequest
(
$request
);
...
...
src/PotageBundle/Resources/views/Membre/today.js
View file @
e8cc1338
...
...
@@ -12,54 +12,3 @@ $("#offre div.item")
$
(
this
).
transition
({
scale
:
1
},
200
,
'
linear
'
);
$
(
this
).
find
(
'
.overlay
'
).
transition
({
opacity
:
0
},
200
,
'
linear
'
);
});
/*
* Formulaire imbriqués, ajouter/enlever des légumes à la commande
* https://symfony.com/doc/3.4/form/form_collections.html
*/
let
holder
;
let
addLink
=
$
(
'
<a href="#" class="add-legume">+</a>
'
);
let
newLi
=
$
(
'
<li></li>
'
).
append
(
addLink
);
jQuery
(
document
).
ready
(
function
()
{
holder
=
$
(
'
ul.commandeLegumes
'
);
holder
.
append
(
newLi
);
holder
.
data
(
'
index
'
,
holder
.
find
(
'
:input
'
).
length
);
addLink
.
on
(
'
click
'
,
function
(
e
)
{
addForm
(
holder
,
newLi
);
});
});
function
addForm
(
holder
,
newLi
)
{
let
prototype
=
holder
.
data
(
'
prototype
'
);
let
index
=
holder
.
data
(
'
index
'
);
let
newForm
=
prototype
;
// You need this only if you didn't set 'label' => false in your tags field in TaskType
// Replace '__name__label__' in the prototype's HTML to
// instead be a number based on how many items we have
// newForm = newForm.replace(/__name__label__/g, index);
// Replace '__name__' in the prototype's HTML to
// instead be a number based on how many items we have
newForm
=
newForm
.
replace
(
/__name__/g
,
index
);
holder
.
data
(
'
index
'
,
index
+
1
);
let
newFormLi
=
$
(
'
<li></li>
'
).
append
(
newForm
);
newFormLi
.
append
(
'
<a href="#" class="remove-legume">x</a>
'
);
newLi
.
before
(
newFormLi
);
$
(
'
.remove-legume
'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$
(
this
).
parent
().
remove
();
return
false
;
});
}
\ 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