method __construct documentation in bbn\Html\Input

This will build a new HTML form element according to the given configuration.

Only name and tag are mandatory, then other values depending on the tag

function($cfg) { if ( \is_string($cfg) ){ $cfg = [ 'field' => 'text', 'attr' => [ 'name' => $cfg ] ]; } parent::__construct($cfg); if ( $this->tag ){ $mandatory_attr = []; if ( !isset($this->attr['id']) ){ $this->attr['id'] = bbn\Str::genpwd(20,15); } $this->script = isset($cfg['script']) ? $cfg['script'] : ''; $this->value = isset($cfg['value']) ? $cfg['value'] : ''; switch ( $this->tag ) { case "input": array_push($mandatory_attr, "type"); break; case "textarea": array_push($mandatory_attr, "cols", "rows"); break; case "select": array_push($mandatory_attr, "attr"); break; } foreach ( $mandatory_attr as $m ){ if ( !isset($this->attr[$m]) ){ die("Argument $m is missing in your config... Sorry!"); } } } return $this; }

This will build a new HTML form element according to the given configuration. 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.