]> git.agnieray.net Git - galette.git/commitdiff
Add missing cancel buttons
authorGuillaume AGNIERAY <dev@agnieray.net>
Sat, 11 Mar 2023 11:15:08 +0000 (12:15 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Sat, 11 Mar 2023 15:10:10 +0000 (16:10 +0100)
galette/lib/Galette/Controllers/Crud/DynamicFieldsController.php
galette/lib/Galette/Controllers/Crud/EntitledsController.php
galette/templates/default/pages/configuration_dynamic_field_form.html.twig
galette/templates/default/pages/configuration_entitled_form.html.twig

index d0119f8455fcd7162edc1e7c0cadd76fe500c41b..4fec63e72a3ebe47c175ddca11208e39e195f795 100644 (file)
@@ -112,6 +112,12 @@ class DynamicFieldsController extends CrudController
         $error_detected = [];
         $warning_detected = [];
 
+        if (isset($post['cancel'])) {
+            return $response
+                ->withStatus(301)
+                ->withHeader('Location', $this->cancelUri($this->getArgs($request)));
+        }
+
         $df = DynamicField::getFieldType($this->zdb, $post['field_type']);
 
         try {
@@ -332,6 +338,12 @@ class DynamicFieldsController extends CrudController
         $post = $request->getParsedBody();
         $post['form_name'] = $form_name;
 
+        if (isset($post['cancel'])) {
+            return $response
+                ->withStatus(301)
+                ->withHeader('Location', $this->cancelUri($this->getArgs($request)));
+        }
+
         $error_detected = [];
         $warning_detected = [];
 
@@ -420,7 +432,7 @@ class DynamicFieldsController extends CrudController
      */
     public function redirectUri(array $args)
     {
-        return $this->routeparser->urlFor('configureDynamicFields');
+        return $this->routeparser->urlFor('configureDynamicFields', ['form_name' => $args['form_name']]);
     }
 
     /**
index a47cc93d10bd67690e43de925a2421819b713d02..c6a1efa8f7bad9894549a0e38b517c9453f3d6c6 100644 (file)
@@ -253,6 +253,12 @@ class EntitledsController extends CrudController
     ): Response {
         $post = $request->getParsedBody();
 
+        if (isset($post['cancel'])) {
+            return $response
+                ->withStatus(301)
+                ->withHeader('Location', $this->cancelUri($this->getArgs($request)));
+        }
+
         $error_detected = [];
         $msg = null;
 
index d512abe7cad1a1805b5bf0dfff787a30bb44f432..d57303de38e8b9a46f84aaf055e94fe7c3342769 100644 (file)
@@ -81,6 +81,8 @@
             <button type="submit" class="ui labeled icon primary button action">
                 <i class="save icon"></i> {{ _T("Save") }}
             </button>
+            <input type="submit" name="cancel" value="{{ _T("Cancel") }}" class="ui button"/>
+            <input type="hidden" name="form_name" id="form_name" value="{{ form_name }}"/>
         </div>
     {% endif %}
             {% include "components/forms/csrf.html.twig" %}
             <button type="submit" name="valid" class="ui labeled icon primary button action">
                 <i class="plus icon"></i> {{ _T("Add") }}
             </button>
+            <input type="submit" name="cancel" value="{{ _T("Cancel") }}" class="ui button"/>
     {% endif %}
             <input type="hidden" name="form_name" id="form_name" value="{{ form_name }}"/>
     {% if mode == 'ajax' %}
index eee70bb5a345914559886dbdd2998434ad4bb2bc..4d3b68b848674cdd8a5ca57eab8972db918f1ea3 100644 (file)
@@ -12,8 +12,8 @@
                 <label for="{{ name }}">{{ _T("Name:") }}</label>
                 <input type="text" name="{{ name }}" id="{{ name }}" value="{% if class == 'Status' %}{{ entry.libelle_statut }}{% else %}{{ entry.libelle_type_cotis }}{% endif %}" />
             </div>
-            <div class="field inline">
 {% if class == 'Status' %}
+            <div class="field inline">
                 <label for="{{ field }}">
                     {{ _T("Priority:") }}
                 </label>
@@ -39,6 +39,7 @@
                 <i class="save icon"></i>
                 {{ _T("Save") }}
             </button>
+            <input type="submit" name="cancel" value="{{ _T("Cancel") }}" class="ui button"/>
         </div>
 {% endif %}
         {% include 'components/forms/csrf.html.twig' %}