Skip to content

Commit

Permalink
handle array fields for text input fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkez committed Jan 30, 2020
1 parent 7db7531 commit 76561e9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/template/tags/input.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
* compliance with the license. Any of the license terms and conditions
* can be waived if you get permission from the copyright holder.
*
* Copyright (c) 2018 ~ ikkez
* Copyright (c) 2020 ~ ikkez
* Christian Knuth <ikkez0n3@gmail.com>
*
* @version: 1.0.0
* @date: 09.05.2018
* @version: 1.1.0
* @date: 30.01.2020
* @since: 07.08.2015
*
**/
Expand Down Expand Up @@ -54,7 +54,13 @@ function build($attr, $content) {

} elseif($attr['type'] != 'password' && !array_key_exists('value',$attr)) {
// all other types, except password fields
$attr['value'] = $this->tmpl->build('{{ isset(@'.$srcKey.$name.')?@'.$srcKey.$name.':\'\'}}');
if (preg_match('/\[\]$/s', $name)) {
$name=substr($name,0,-2);
$kh='__'.$this->f3->hash($name);
$cond = '(isset(@'.$srcKey.$name.') && is_array(@'.$srcKey.$name.'))?@'.$srcKey.$name.'[(!isset(@'.$kh.')?(@'.$kh.'=0):++@'.$kh.')]:\'\'';
} else
$cond = 'isset(@'.$srcKey.$name.')?@'.$srcKey.$name.':\'\'';
$attr['value'] = $this->tmpl->build('{{'.$cond.'}}');
}
}
// resolve all other / unhandled tag attributes
Expand Down

0 comments on commit 76561e9

Please sign in to comment.