From: Mischa POSLAWSKY Date: Sat, 16 Jun 2018 21:30:33 +0000 (+0200) Subject: login/edit: build input html from prepared attributes X-Git-Tag: v3.2~5 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/0fc1504852e9630502651eaa35c2c04ba777bda3 login/edit: build input html from prepared attributes Same results, easier to maintain. --- diff --git a/login/edit.php b/login/edit.php index 4e52506..6dfbfab 100644 --- a/login/edit.php +++ b/login/edit.php @@ -124,18 +124,32 @@ foreach ($cols as $col => &$colconf) { 200, $colconf['target'], filemtime($colconf['target']) ); } - print " @$colconf['type'] ?: 'text', + 'name' => $col, + 'id' => $col, + 'value' => htmlspecialchars(@$colconf['value']), + 'placeholder' => "Niet ingesteld", + 'readonly' => empty($colconf['target']), + ]; + if (@$colconf['type'] == 'file') { + $attrs['accept'] = "image/jpeg"; + } + + print ' $attrval) { + if ($attrval === FALSE) { + continue; + } + print ' ' . $attr; + if ($attrval !== TRUE) { + printf('="%s"', $attrval); + } + } + print ' />'; } - print ' placeholder="Niet ingesteld"'; - print " />"; if ($error = @$colwarn[$col]) { print " $error\n";