Generate checkbox by group.

@param  string  $id
@param  string  $label
@param  string  $name
@param  bool|array  $checked
@param  array  $options

@return array
512558
protected function generateCheckboxByGroup($id, $label, $name, $checked, array $options)
    {
        $identifier = \sprintf('%s_%s', $name, $id);
        $key = \sprintf('%s[]', $name);
        $active = \in_array($id, (array) $checked);

        $options['id'] = $identifier;

        $control = $this->checkbox($key, $id, $active, $options);

        $label = $this->label($identifier, $label);

        return \implode(' ', [$control, $label]);
    }
494691
public function checkboxes($name, array $list = [], $checked = null, array $options = [], $separator = '<br>')
    {
        $group = [];
        $name = \str_replace('[]', '', $name);

        foreach ($list as $id => $label) {
            $group[] = $this->generateCheckboxByGroup($id, $label, $name, $checked, $options);
        }

        return \implode($separator, $group);
    }
259684
public function radio($name, $label = null, $value = null, $checked = null, array $options = [])
    {
        $inputElement = $this->radioElement($name, $label, $value, $checked, false, $options);

        $wrapperOptions = $this->isHorizontal() ? ['class' => implode(' ', [$this->getLeftColumnOffsetClass(), $this->getRightColumnClass()])] : [];
        $wrapperElement = '<div' . $this->html->attributes($wrapperOptions) . '>' . $inputElement . '</div>';

        return $this->getFormGroup(null, $label, $wrapperElement);
    }
16477
public function select($name, $id, $options = [], array $attr = null)
    {
        $basic = $this->merge_attr([ 'id' => $id ], $attr);

        return $this->input($name, [ 'type' => 'select', 'options' => $options, 'attr' => $basic ]);
    }
1044575
public function checkbox($name, $value = '', $checked = false, $attributes = array())
    {
        if ($checked) {
            $attributes['checked'] = 'checked';
        } else {
            unset($attributes['checked']);
        }

        return $this->input('checkbox', $name, $value, $attributes);
    }
83254
public function label($label, $id = null, array $attributes = array())
	{
		if (is_array($label))
		{
			$attributes = $label;
			$label = $attributes['label'];
			isset($attributes['id']) and $id = $attributes['id'];
		}

		if (empty($attributes['for']) and $this->get_config('auto_id', false) == true)
		{
			empty($id) or $attributes['for'] = $this->get_config('auto_id_prefix', 'form_').$id;
		}

		unset($attributes['label']);

		return html_tag('label', $attributes, \Lang::get($label, array(), false) ?: $label);
	}
1292165
public function addCheckbox($name, $label = '', $multi  = [], $attr = [] )
    {
        $e = new \FrenchFrogs\Form\Element\Checkbox($name, $label, $multi, $attr);
        $this->addElement($e);
        return $e;
    }
1297540
protected function option_group(
		$list,
		$label,
		$selected,
		array $attributes = [],
		array $options_attributes = [],
		$level = 0
	) {
		$html  = [];

		$space = str_repeat( '&nbsp;', $level );

		foreach ( $list as $value => $display ) {
			$option_attributes = Arr::get( $options_attributes, $value, [] );

			if ( is_iterable( $display ) ) {
				$html[] = $this->option_group( $display, $value, $selected, $attributes, $option_attributes, $level + 5 );
			} else {
				$html[] = $this->option( $space . $display, $value, $selected, $option_attributes );
			}
		}

		return $this->to_html_string( '<optgroup label="' . esc_attr( $space . $label ) . '"' . $this->attributes( $attributes ) . '>' . implode( '', $html ) . '</optgroup>' );
	}
10721
public function radioElement($name, $label = null, $value = null, $checked = null, $inline = false, array $options = [])
    {
        $label = $label === false ? null : $this->getLabelTitle($label, $name);

        $value = is_null($value) ? $label : $value;

        $labelOptions = $inline ? ['class' => 'radio-inline'] : [];

        $inputElement = $this->form->radio($name, $value, $checked, $options);
        $labelElement = '<label ' . $this->html->attributes($labelOptions) . '>' . $inputElement . $label . '</label>';

        return $inline ? $labelElement : '<div class="radio">' . $labelElement . '</div>';
    }
215019
public static function label($label, $id = null, array $attributes = array())
	{
		return static::$instance->label($label, $id, $attributes);
	}
1024717
public static function check( $name, $checked = false, $attribs = array() ) {
		return self::element(
			'input', array_merge(
				array(
					'name'  => $name,
					'type'  => 'checkbox',
					'value' => 1
				),
				self::attrib( 'checked', $checked ),
				$attribs
			)
		);
	}
490384
static public function checkbox_group($name, $value=null, $settings=[], $is_radio=false)
    {
        $form_type  = $is_radio ? 'radio' : 'checkbox';
        
        if (!$is_radio && strpos($name, '[]') === false) {
            $name .= '[]';
        }
        $settings = static::formatSettings($settings);
        
        $form_id = isset($settings['id']) ? $settings['id'] : static::formatId($name);
        unset($settings['id']);
        
        $classes = isset($settings['class']) ? explode(' ', $settings['class']) : [];
        $css_inline = (isset($settings['form-inline']) && $settings['form-inline'])|| in_array('inline', $classes) || in_array('list-inline', $classes) ? : false;
        $classes = array_diff($classes, ['inline', 'list-inline']);
        array_push($classes, 'ace');
        $settings['class'] = implode(' ', $classes);
        
        $str = sprintf('<ul class="control-group list-unstyled%s">', $css_inline ? ' list-inline' : '') . PHP_EOL;
        
        if ($settings['data_source']) {
            $fields     = $settings['fields'];
            foreach ($settings['data_source'] as $k => $v) {
                if (is_scalar($v)) {
                    $_value = $k;
                    $_title = $v;
                } else {
                    $_value = isset($v[$fields[0]]) ? $v[$fields[0]] : 0;
                    $_title = isset($v[$fields[1]]) ? $v[$fields[1]] : (isset($v['name']) ? $v['name'] : '无法解析名称');
                }
                // checked, if set value-bit(value like 1,2,4) then use bit type
                if (isset($settings['value-bit']) && $settings['value-bit']) {
                    $checked = (intval($value) & $_value) ? ' checked="checked"' : '';
                } else {
                    $checked_values = isset($settings['checked']) ? $settings['checked'] : $value;
                    $checked_values = is_null($checked_values) || $checked_values === '' ? [] : (array) $checked_values;
                    $checked = in_array($_value, $checked_values) ? ' checked="checked"' : '';
                }
                
                $str .= sprintf('<li class="%s">', $css_inline ? '' : 'list-group-item') . PHP_EOL;
                if (isset($v['depth'])) $str .= str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $v['depth']);
                $str .= '   <input type="'.$form_type.'" name="'. $name .'" value="'.$_value.'" class="' . $settings['class'] . '" data-group="'.$_title.'" '.$checked.' > ' . PHP_EOL;
                $str .= '   <span class="lbl"> '.$_title.' </span> ' . PHP_EOL;
                $str .= '</li>' . PHP_EOL;
            }
        } else {
            $str .= '<li>' . PHP_EOL;
            $str .= static::$form_type($name, $value, $settings);
            $str .= '</li>' . PHP_EOL;
        }
        
        $str .= '</ul>' . PHP_EOL;
        return $str;
    }
820139
static function laraform($name = '', $options, $is_inline = true) {
        $gr = new ElementGroupCheckboxTwbs($name);
        if ($is_inline) {
            $gr->setIsInline(true);
        }
        foreach ($options as $k => $v) {
            $gr->putCheckboxTwbs($k, $k)
                ->setLabel($v);
        }
        return $gr;
    }
1244200
private function createOptgroupNode($label, array $list)
    {
        $optgroup = new NodeElement();
        $optgroup->openTag('optgroup')
                 ->addAttribute('label', $label)
                 ->finalize();

        foreach ($this->getOptions($list) as $option) {
            $optgroup->appendChild($option);
        }

        $optgroup->closeTag();

        return $optgroup;
    }
1112298
public function tab($name, array $options = [])
    {
        if (!isset($options['label'])) {
            $options['label'] = 'form.tab_' . $name;
        }

        return parent::tab($name, $options);
    }
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);
    }
148587
public static function label( $name, $label, $help = '', $options = null ) {

		if ( is_array( $label ) || is_object( $label ) ) {
			$options = $label;
			$label   = $options['label'];

			if ( empty( $label ) ) {
				$label = ucwords( str_replace( '_', ' ', $name ) );
			}

			$help = $options['help'];
		} else {
			$options = self::options( null, $options );
		}

		$label = apply_filters( 'pods_form_ui_label_text', $label, $name, $help, $options );
		$help  = apply_filters( 'pods_form_ui_label_help', $help, $name, $label, $options );

		ob_start();

		$name_clean      = self::clean( $name );
		$name_more_clean = self::clean( $name, true );

		$type                = 'label';
		$attributes          = array();
		$attributes['class'] = 'pods-form-ui-' . $type . ' pods-form-ui-' . $type . '-' . $name_more_clean;
		$attributes['for']   = ( false === strpos( $name_clean, 'pods-form-ui-' ) ? 'pods-form-ui-' : '' ) . $name_clean;
		$attributes          = self::merge_attributes( $attributes, $name, $type, $options, false );

		pods_view( PODS_DIR . 'ui/fields/_label.php', compact( array_keys( get_defined_vars() ) ) );

		$output = ob_get_clean();

		return apply_filters( "pods_form_ui_{$type}", $output, $name, $label, $help, $attributes, $options );
	}