Source of file Checkbox.php
Size: 1,019 Bytes - Last Modified: 2017-11-08T13:54:24+00:00
/home/travis/build/bluzphp/framework/src/View/Helper/Checkbox.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | <?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ declare(strict_types=1); namespace Bluz\View\Helper; use Bluz\View\View; /** * Generate HTML for <input type="checkbox"> * * @author The-Who * * @var View $this * * @param string $name * @param string|null $value * @param bool $checked * @param array $attributes * * @return string */ return function ($name, $value = null, $checked = false, array $attributes = []) { /** @var View $this */ if (true === $checked) { $attributes['checked'] = 'checked'; } elseif (false !== $checked && ($checked === $value)) { $attributes['checked'] = 'checked'; } if (null !== $value) { $attributes['value'] = $value; } $attributes['name'] = $name; $attributes['type'] = 'checkbox'; return '<input ' . $this->attributes($attributes) . '/>'; }; |