login/edit: generic setup of input attributes
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 8 Nov 2018 17:25:20 +0000 (18:25 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 13 Nov 2018 16:30:57 +0000 (17:30 +0100)
login/edit.inc.php
login/edit.php

index b94fa7cd786a63bc4707bafc1ff374b6aaabbad6..77bfc9b5bd246df94271defa965a27a992841265 100644 (file)
@@ -4,8 +4,10 @@ $cols = [
                'label' => 'login',
                'value' => $user['name'],
                'target' => NULL,
-               'pattern' => "[a-z0-9-]+",
-               'size' => 10,
+               'attr' => [
+                       'pattern' => "[a-z0-9-]+",
+                       'size' => 10,
+               ],
        ],
        'name'  => [
                'label' => 'volledige naam',
@@ -24,6 +26,9 @@ $cols = [
        'avatar' => [
                'label' => 'portretfoto',
                'type' => 'file',
+               'attr' => [
+                       'accept' => "image/jpeg",
+               ],
                'filename' => 'avatar.jpg',
        ],
        'tags' => [
index 2b043cc24a1f427e68e2a5504ea088023141a884..99afb13a62b745cfe08068c340815aa480cb1ff4 100644 (file)
@@ -217,12 +217,7 @@ foreach ($cols as $col => &$colconf) {
                        'value'       => htmlspecialchars(@$colconf['value']),
                        'placeholder' => "Niet ingesteld",
                        'readonly'    => empty($colconf['target']),
-                       'pattern'     => @$colconf['pattern'] ?: FALSE,
-                       'size'        => @$colconf['size'] ?: FALSE,
-               ];
-               if (@$colconf['type'] == 'file') {
-                       $attrs['accept'] = "image/jpeg";
-               }
+               ] + (@$colconf['attr'] ?: []);
 
                print '<input';
                foreach ($attrs as $attr => $attrval) {