method input documentation in bbn\Html\Builder

Generates a whole input configuration array by combining the passed and default configurations

function($cfg = []) { if ( \is_array($cfg) && isset($cfg['attr']['name']) ){ self::giveId($cfg); if ( isset($cfg['field']) ){ $cfg = bbn\X::mergeArrays(self::specs('fields', $cfg['field']), $cfg); } /* if ( !isset($cfg['tag']) ){ $cfg['tag'] = 'input'; } if ( !isset($cfg['attr']['type']) ){ $cfg['attr']['type'] = 'text'; } */ if ( isset($cfg['data']) ){ if ( isset($cfg['data']['sql'], $this->_current_cfg['data']['db']) ){ $db =& $this->_current_cfg['data']['db']; if ( !isset($cfg['widget']['options']['dataSource']) ){ $cfg['widget']['options']['dataSource'] = []; } $count = ( $r = $db->query($cfg['data']['sql']) ) ? $r->count() : 0; if ( $count <= self::max_values_at_once ){ if ( $ds = $db->getIrows($cfg['data']['sql']) ){ foreach ( $ds as $d ){ if ( \count($d) > 1 ){ array_push($cfg['widget']['options']['dataSource'], [ 'value' => $d[0], 'text' => $d[1] ]); } else{ array_push($cfg['widget']['options']['dataSource'], $d[0]); } } } } else{ $cfg['field'] = 'autocomplete'; } } else if ( \is_array($cfg['data']) && (\count($cfg['data']) > 0) ){ if ( isset($cfg['data'][0]) ){ $cfg['widget']['options']['dataSource'] = $cfg['data']; } else{ $cfg['widget']['options']['dataSource'] = []; foreach ( $cfg['data'] as $k => $v ){ array_push($cfg['widget']['options']['dataSource'], [ 'value' => $k, 'text' => $v ]); } } } if ( isset($cfg['widget']['options']['dataSource'][0]['text']) ){ $cfg['widget']['options']['dataTextField'] = 'text'; $cfg['widget']['options']['dataValueField'] = 'value'; } } if ( \is_array($cfg) ){ // Size calculation if ( isset($cfg['attr']['maxlength']) && !isset($cfg['attr']['size']) ){ if ( $cfg['attr']['maxlength'] <= 20 ){ $cfg['attr']['size'] = (int)$cfg['attr']['maxlength']; } } if ( isset($cfg['attr']['size'], $cfg['attr']['minlength']) && $cfg['attr']['size'] < $cfg['attr']['minlength']){ $cfg['attr']['size'] = (int)$cfg['attr']['minlength']; } $cfg = array_filter($cfg, function($a){ return !( \is_array($a) && \count($a) === 0 ); }); } if ( isset($cfg['null']) && $cfg['null'] ){ if ( empty($cfg['attr']['value']) ){ $cfg['attr']['value'] = null; $cfg['attr']['disabled'] = true; if ( isset($cfg['widget']) ){ if ( !isset($cfg['script']) ){ $cfg['script'] = ''; } /* $cfg['script'] .= 'if ( $("#'.$cfg['attr']['id'].'").data("'.$cfg['widget']['name'].'") ){ $("#'.$cfg['attr']['id'].'").data("'.$cfg['widget']['name'].'").enable(false); } else if ( $("#'.$cfg['attr']['id'].'").'.$cfg['widget']['name'].' ){ $("#'.$cfg['attr']['id'].'").'.$cfg['widget']['name'].'("enable", false); }'; * */ } } } $t = new Input($cfg); return $t; } return false; }

Generates a whole input configuration array by combining the passed and default configurations BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.