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
T
technobel.sf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
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
technobel.sf
Commits
d1215d45
Commit
d1215d45
authored
Jul 12, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init nouvelle page biere.html, affiche formulaire biere
parent
2dfef772
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
2 deletions
+145
-2
0ne/orig/ajax/biere.html
0ne/orig/ajax/biere.html
+47
-0
src/Api2Bundle/Controller/BiereController.php
src/Api2Bundle/Controller/BiereController.php
+29
-0
src/Api2Bundle/Entity/Biere.php
src/Api2Bundle/Entity/Biere.php
+26
-2
src/Api2Bundle/Form/BiereType.php
src/Api2Bundle/Form/BiereType.php
+43
-0
No files found.
0ne/orig/ajax/biere.html
0 → 100755
View file @
d1215d45
<!doctype html>
<html
lang=
"fr"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Bière
</title>
</head>
<body>
<h2>
Bière
</h2>
<form
id=
"biere"
>
<label
for=
"nom"
>
Nom
</label>
<input
type=
"text"
name=
"nom"
><br>
<label
for=
"degre"
>
Degré
</label>
<input
type=
"text"
name=
"degre"
><br>
<label
for=
"capacite"
>
Capacité
</label>
<input
type=
"text"
name=
"capacite"
><br>
<label
for=
"brasserie"
>
Brasserie
</label>
<select
name=
"brasserie"
>
</select><br>
<label
for=
"file"
>
Image
</label>
<input
type=
"file"
name=
"file"
>
<button
id=
"send"
>
Envoyer
</button>
</form>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
></script>
<script>
$
(
document
).
ready
(
function
()
{
$
.
get
(
"
http://0.0.0.0:81/web/app_dev.php/API/v2/brasserie
"
,
function
(
data
){
for
(
let
item
of
data
)
{
$
(
'
select[name=brasserie]
'
).
append
(
`<option value="
${
item
.
id
}
">
${
item
.
nom
}
</option>`
);
}
}
);
});
</script>
</body>
</html>
\ No newline at end of file
src/Api2Bundle/Controller/BiereController.php
0 → 100755
View file @
d1215d45
<?php
namespace
Api2Bundle\Controller
;
use
Api2Bundle\Entity\Biere
;
use
Api2Bundle\Form\BiereType
;
use
FOS\RestBundle\Controller\Annotations
as
Rest
;
use
FOS\RestBundle\Controller\FOSRestController
;
use
Symfony\Component\HttpFoundation\Request
;
class
BiereController
extends
FOSRestController
{
/**
* @param Request $request
* @Rest\Post(path="/biere")
* @Rest\View()
* @return int
*/
public
function
postAction
(
Request
$request
)
{
$biere
=
new
Biere
();
$form
=
$this
->
createForm
(
BiereType
::
class
,
$biere
);
$form
->
handleRequest
(
$request
);
dump
(
$biere
);
return
0
;
}
}
src/Api2Bundle/Entity/Biere.php
View file @
d1215d45
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
Api2Bundle\Entity
;
namespace
Api2Bundle\Entity
;
use
Doctrine\ORM\Mapping
as
ORM
;
use
Doctrine\ORM\Mapping
as
ORM
;
use
Symfony\Component\HttpFoundation\File\UploadedFile
;
/**
/**
* Biere
* Biere
...
@@ -24,7 +25,7 @@ class Biere
...
@@ -24,7 +25,7 @@ class Biere
/**
/**
* @var Categorie
* @var Categorie
* @ORM\ManyToOne(targetEntity="Api2Bundle\Entity\Categorie")
* @ORM\ManyToOne(targetEntity="Api2Bundle\Entity\Categorie")
* @ORM\JoinColumn(name="id_categorie", nullable=
fals
e)
* @ORM\JoinColumn(name="id_categorie", nullable=
tru
e)
*/
*/
private
$categorie
;
private
$categorie
;
...
@@ -59,6 +60,11 @@ class Biere
...
@@ -59,6 +60,11 @@ class Biere
*/
*/
private
$image
;
private
$image
;
/**
* @var UploadedFile
*
*/
private
$file
;
/**
/**
* Get id
* Get id
...
@@ -178,5 +184,23 @@ class Biere
...
@@ -178,5 +184,23 @@ class Biere
return
$this
;
return
$this
;
}
}
/**
* @return UploadedFile
*/
public
function
getFile
()
{
return
$this
->
file
;
}
/**
* @param UploadedFile $file
* @return Biere
*/
public
function
setFile
(
$file
)
{
$this
->
file
=
$file
;
return
$this
;
}
}
}
src/Api2Bundle/Form/BiereType.php
0 → 100755
View file @
d1215d45
<?php
namespace
Api2Bundle\Form
;
use
Symfony\Component\Form\AbstractType
;
use
Symfony\Component\Form\FormBuilderInterface
;
use
Symfony\Component\OptionsResolver\OptionsResolver
;
class
BiereType
extends
AbstractType
{
/**
* {@inheritdoc}
*/
public
function
buildForm
(
FormBuilderInterface
$builder
,
array
$options
)
{
$builder
->
add
(
'nom'
)
->
add
(
'degre'
)
->
add
(
'capacite'
)
->
add
(
'file'
)
->
add
(
'brasserie'
);
}
/**
* {@inheritdoc}
*/
public
function
configureOptions
(
OptionsResolver
$resolver
)
{
$resolver
->
setDefaults
(
array
(
'data_class'
=>
'Api2Bundle\Entity\Biere'
));
}
/**
* {@inheritdoc}
*/
public
function
getBlockPrefix
()
{
return
''
;
}
}
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