Creates a toggle checkbox.

@param string $name
@param array  $options

@return Checkbox
486888
protected function createCheckbox($name, $options)
    {
        $box = new Checkbox($name, $options);
        $box->setAttribute('checked', true)
            ->setAttribute(
                'id',
                preg_replace(
                    array('~\[~', '~\]~', '~--+~', '~-$~'),
                    array('-', '', '-', ''),
                    $name
                )
            );

        return $box;
    }
768364
public function alterTable($name, array $options = [])
    {
        $schema = isset($options['schema']) ? new Schema($options['schema']) : null;

        return (new TableApi($name, $schema, $this->manipulation, $this->actions))
            ->alterTable();
    }
782670
protected function checkable($type, $name, $value, $checked, $options)
    {
        $checked = $this->getCheckedState($type, $name, $value, $checked);

        if ($checked) {
            $options['checked'] = 'checked';
        }

        return $this->input($type, $name, $value, $options);
    }
469271
public function get($name, array $options = [])
    {
        $group = $options['group'];

        $menuItem = $this->menuFactory->createItem($options['name']);

        if (empty($group['on_top']) || false === $group['on_top']) {
            foreach ($group['items'] as $item) {
                if ($this->canGenerateMenuItem($item, $group)) {
                    $menuItem->addChild($this->generateMenuItem($item, $group));
                }
            }

            if (false === $menuItem->hasChildren()) {
                $menuItem->setDisplay(false);
            } elseif (!empty($group['keep_open'])) {
                $menuItem->setAttribute('class', 'keep-open');
                $menuItem->setExtra('keep_open', $group['keep_open']);
            }
        } elseif (1 === \count($group['items'])) {
            if ($this->canGenerateMenuItem($group['items'][0], $group)) {
                $menuItem = $this->generateMenuItem($group['items'][0], $group);
                $menuItem->setExtra('on_top', $group['on_top']);
            } else {
                $menuItem->setDisplay(false);
            }
        }
        $menuItem->setLabel($group['label']);

        return $menuItem;
    }
1006923
public function button(string $name, array $options = []): FieldTypeInterface
    {
        return (new ButtonType($name))
            ->setLocale($this->app->getLocale())
            ->setViewFactory($this->viewFactory)
            ->setOptions($options);
    }
1207887
public static function make($name, array $options = []): self
    {
        $class = new ReflectionClass($options['class'] ?? static::class);

        /* @var static $instance */
        $instance = $class->newInstanceWithoutConstructor();
        $instance->setName($name);
        $instance->setOptions($options);

        return $instance;
    }
386006
protected function doCreateCollection($name, array $options)
    {
        $this->mongoDB->createCollection($name, $options);

        return $this->doSelectCollection($name);
    }
369119
public static function select($name, $options, $attributes = array())
    {
        // Extract the value
        $value = isset($attributes['value']) ? $attributes['value'] : null;
        unset($attributes['value']);

        // Set the name
        $attributes['name'] = $name;

        // Set the id to the name if one
        // is not already set.
        if (!isset($attributes['id'])) {
            $attributes['id'] = $name;
        }

        // Opening tag
        $select = array();
        $select[] = "<select " . HTML::buildAttributes($attributes) . ">";

        // Options
        foreach ($options as $index => $option) {
            if (!is_numeric($index)) {
                $select[] = '<optgroup label="' . $index . '">';
                foreach ($option as $opt) {
                    $select[] = static::selectOption($opt, $value);
                }
                $select[] = '</optgroup>';
            } else {
                $select[] = static::selectOption($option, $value);
            }
        }

        // Closing tags
        $select[] = '</select>';

        return implode(PHP_EOL, $select);
    }
916491
public function button($name, array $options = []) {
        $options += [
            'type' => 'button'
        ];
        $options = $this->addClass($options, 'navbar-btn');
        return $this->Form->button($name, $options);
    }
960636
public function create($name, $type, array $options)
    {
        if (is_string($type)) {
            $type = $this->registry->getType($type);
        }
        if (!$type instanceof WidgetTypeInterface) {
            throw new \InvalidArgumentException('Unexpected widget type.');
        }

        $options['name'] = $name;

        $resolver = new OptionsResolver();
        $type->configureOptions($resolver);
        $options = $resolver->resolve($options);

        $widget = new Widget($name, $type);
        $type->buildWidget($widget, $options);

        return $widget;
    }
1099285
public function createCollection($name, array $options = [])
    {
        return $this->bridge->createCollection($this->cName($name), $options);
    }
271092
public function button($name, $options = array())
    {
        $options += array(
            "type" => "button",
            "label" => "Button",
            "id"    => $this->id($name),
            "name"  => $this->name($name),
        );

        $label = $options["label"];
        unset($options["label"]);

        return sprintf('<button %s>%s</button>', $this->arrayToHtmlAttributes($options), $label);
    }
1101757
public function icon($name, array $options = [])
    {
        $options += [
            'tag' => 'i',
            'iconSet' => 'glyphicon',
            'class' => null,
        ];

        $classes = [$options['iconSet'], $options['iconSet'] . '-' . $name];
        $options = $this->injectClasses($classes, $options);

        return $this->formatTemplate('tag', [
            'tag' => $options['tag'],
            'attrs' => $this->templater()->formatAttributes($options, ['tag', 'iconSet']),
        ]);
    }
30007
public function create($name, $type = null, array $options = [])
    {
        return $this->formBuilder->create($name, $type, $options);
    }
370445
public function selectCollection($name, array $options = [])
    {
        if (!isset($this->collections[$name])) {
            $this->createCollection($name);
        }
        return $this->collections[$name]['collection'];
    }
906882
public function checkbox($options)
    {

        if (is_string($options)) {
            $options = ['class' => $options];
        }

        if (!Arr::has($options, 'type')) {
            Arr::set($options, 'type', 'checkbox');
        }

        return $this->input($options);
    }
366530
public static function checkboxList($name, $selection = null, $items = [], $options = [])
    {
        if (!isset($options['item'])) {
            $itemOptions = ArrayHelper::remove($options, 'itemOptions', []);
            $encode = ArrayHelper::getValue($options, 'encode', true);
            $options['item'] = function ($index, $label, $name, $checked, $value) use ($itemOptions, $encode) {
                $options = array_merge([
                    'label' => $encode ? static::encode($label) : $label,
                    'value' => $value
                ], $itemOptions);
                return '<div class="checkbox">' . Html::checkbox($name, $checked, $options) . '</div>';
            };
        }

        return parent::checkboxList($name, $selection, $items, $options);
    }