1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| {% extends 'users.html.twig' %}
{% block title %}Ajouter Une Annonce{% endblock %}
{% block stylesheets%}
<!-- Axentix CSS minified version -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/axentix@1.0.0-beta.2/dist/css/axentix.min.css">
<link href="/css/style.css" rel="stylesheet">
<link href="/css/css/all.css" rel="stylesheet">
{% endblock %}
{% block body %}
<div class=" container ">
<div class="card shadow-1 rounded-3 mt-5">
{% for flashError in app.flashes('error') %}
<div class="alert alert-danger" role="alert">{{ flashError }}</div>
{% endfor %}
<div class="card-header badge badge-success d-grid txt-center txt-white">Ajouter Une Nouvelle Annonce</div>
<div class="card-content">
{{ form_start(form) }}
<div class="form-group">
<label class="col-sm-4 col-md-4 control-label" for="titre">Titre:</label>
<div class="col-sm-5 col-md-5">
{{ form_widget(form.title, {'attr': {'class': 'form-control'}}) }}
</div>
<label class="col-sm-4 col-md-4 control-label" for="categories" value="categories">Categorie:</label>
<div id ="myDiv"class="col-sm-5 col-md-5">
{{ form_widget(form.categories,{'attr': {'class': 'form-control','onchange':'myFunction()'}}) }}
</div>
<div id="souscategories" data-prototype="{{ form_row(form.souscategories.vars.prototype)|e('html_attr') }}">
{{ form_row(form.souscategories) }}
<span></span>
</div>
<label class="col-sm-4 col-md-4 control-label" for="prix">Prix:</label>
<div class="col-sm-5 col-md-5">
{{ form_widget(form.price, {'attr': {'class': 'form-control'}})}}
</div>
<label class="col-sm-4 col-md-4 control-label" for="region">Région:</label>
<div class="col-sm-5 col-md-5">
{{ form_widget(form.regions, {'attr': {'class': 'form-control'}})}}
</div>
<label class="col-sm-4 col-md-4 control-label" for="departements">Departement:</label>
<div class="col-sm-5 col-md-5">
{{ form_widget(form.departements, {'attr': {'class': 'form-control'}})}}
</div>
<label class="col-sm-4 col-md-4 control-label" for="images">Image(s):</label>
<div class="col-sm-5 col-md-5">
{{ form_widget(form.images, {'attr': {'class': 'form-control'}}) }}
</div>
<label class="col-sm-4 col-md-4 control-label" for="contenu">Contenu:</label>
<div class="col-sm-">
{{ form_widget(form.content, {'attr': {'class': 'form-control'}}) }}
{{ form_widget(form)}}
</div>
</div>
{{ form_end(form) }}
</div>
</div>
{% endblock %}
{% block javascripts %}
<script>
window.onload=()=>{
//on va chercher la région
let region=document.querySelector("#annonces_regions");
region.addEventListener("change",function(){
let form=this.closest("form");
let data = this.name + "=" + this.value;
console.log(data);
fetch(form.action,{
method: form.getAttribute("method"),
body : data,
headers : {
"content-type":"application/x-www-form-urlencoded;charset:utf-8"
}
})
.then(response=> response.text())
.then(html=>{
let content =document.createElement("html");
content.innerHTML=html;
let nouveauSelect=content.querySelector("#annonces_departements");
document.querySelector("#annonces_departements").replaceWith
(nouveauSelect);
})
.catch(error=>{
console.log(error);
})
})
}
</script>
{% endblock %} |
Partager