diff --git a/src/CoursEndingBundle/Resources/public/js/app.js b/src/CoursEndingBundle/Resources/public/js/app.js
index 1caf588..af9b73e 100644
--- a/src/CoursEndingBundle/Resources/public/js/app.js
+++ b/src/CoursEndingBundle/Resources/public/js/app.js
@@ -1,4 +1,6 @@
-new Vue({
+Vue.config.debug = true;
+Vue.config.devtools = true;
+var x = new Vue({
el: '#forms-render',
data: {
@@ -12,21 +14,46 @@ new Vue({
methods: {
fetchForms: function() {
this.$http.get(Routing.generate('api_get_forms'), function(forms) {
+ for (var i = 0; i < forms.data.length; i++) {
+ forms.data[i].errors = {};
+ }
this.$set('forms', forms.data);
});
},
save: function() {
+ var that = this;
var data = {
forms: {
forms: this.forms
}
};
- this.$http.post(
- Routing.generate('api_post_forms'),
- data
- );
+ this.$http.post(Routing.generate('api_post_forms'), data)
+ .success(function (data) {
+ console.log(data);
+ })
+ .error(function (data) {
+ console.log(data);
+ if (data.hasOwnProperty("code") && data.code === 400
+ && data.hasOwnProperty('message') && data.message === "Validation Failed" ) {
+ var k = 0;
+ for (var i = 0; i < data.errors.children.forms.children.length; i++) {
+ var form = data.errors.children.forms.children[i];
+ //console.log(form);
+ for ( var j in form ) {
+ var errorsInputs = form[j];
+ //console.log(errorsInputs);
+ that.forms[k].errors = errorsInputs;
+ //that.forms[k].label = 'toto';
+
+ k++;
+ }
+ }
+ console.log(that.forms);
+ //that.$set('forms', that.forms); //change rien avec ou sans
+ }
+ });
}
}
})
diff --git a/src/CoursEndingBundle/Resources/views/Main/index.html.twig b/src/CoursEndingBundle/Resources/views/Main/index.html.twig
index e36b825..e82cc60 100644
--- a/src/CoursEndingBundle/Resources/views/Main/index.html.twig
+++ b/src/CoursEndingBundle/Resources/views/Main/index.html.twig
@@ -2,12 +2,13 @@
{% block body %}
-{{form_row(form.forms)}}
-
-{{ form_rest(form) }}
-
-
+{#{{ form_row(form.forms) }}#}
+{##}
+{#{{ form_rest(form) }}#}
+
+
+
diff --git a/web/app_dev.php b/web/app_dev.php
index 635bf7a..697665f 100644
--- a/web/app_dev.php
+++ b/web/app_dev.php
@@ -12,7 +12,7 @@ use Symfony\Component\Debug\Debug;
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
- || !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
+ || !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1','192.168.33.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');