* zin: add checkbox.

This commit is contained in:
dingyongliang
2023-02-07 17:07:23 +08:00
parent 2b588a6215
commit 321aa7c8ed
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace zin\wg;
require_once dirname(dirname(__DIR__)) . DS . 'core' . DS . 'wg.class.php';
require_once dirname(__DIR__) . DS . 'btn' . DS . 'v1.php';
use \zin\core\h5;
use function zin\set;
class checkbox extends \zin\core\wg
{
static $tag = 'label';
static $defaultProps = array('class' => 'checkbox w-28');
static $customProps = 'text,checked';
static function create($props)
{
$checkbox = new checkbox();
foreach($props as $key => $value) $checkbox->prop($key, $value);
return $checkbox;
}
protected function build($isPrint = false, $parent = null)
{
$builder = parent::build($isPrint, $parent);
$input = h5::input(set('type', 'checkbox'));
if ($this->prop('checked')) $input->append(set('checked', 'true'));
$builder->append($input);
$builder->append($this->prop('text'));
return $builder;
}
}