Browse code

Allow saving of GridPosition widget value

Benjamin Roth authored on28/02/2025 14:54:44
Showing1 changed files
... ...
@@ -8,9 +8,7 @@ use Contao\Widget;
8 8
 
9 9
 class GridPosition extends Widget
10 10
 {
11
-    /**
12
-     * @inheritdoc
13
-     */
11
+    protected $blnSubmitInput = true;
14 12
     protected $strTemplate = 'be_grid_position';
15 13
 
16 14
     protected $parent;
... ...
@@ -43,7 +41,6 @@ class GridPosition extends Widget
43 41
         }
44 42
     }
45 43
 
46
-
47 44
     public function generate()
48 45
     {
49 46
         return $this->parse();
Browse code

Add new GridPosition widget

Benjamin Roth authored on28/02/2025 10:55:44
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,51 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
+
5
+namespace vonRotenberg\CoretoolsBundle\Widget;
6
+
7
+use Contao\Widget;
8
+
9
+class GridPosition extends Widget
10
+{
11
+    /**
12
+     * @inheritdoc
13
+     */
14
+    protected $strTemplate = 'be_grid_position';
15
+
16
+    protected $parent;
17
+
18
+    protected $intCols = 6;
19
+
20
+    protected $intRows = 1;
21
+
22
+    public function __construct($arrAttributes = null)
23
+    {
24
+        parent::__construct($arrAttributes);
25
+
26
+        $this->parent = $this->activeRecord;
27
+    }
28
+
29
+    public function __set($strKey, $varValue)
30
+    {
31
+        switch ($strKey)
32
+        {
33
+            case 'rows':
34
+                $this->intRows = $varValue;
35
+                break;
36
+
37
+            case 'cols':
38
+                $this->intCols = $varValue;
39
+                break;
40
+            default:
41
+                parent::__set($strKey, $varValue);
42
+                break;
43
+        }
44
+    }
45
+
46
+
47
+    public function generate()
48
+    {
49
+        return $this->parse();
50
+    }
51
+}