public function flag($fieldName, $options = []) {
		if (!empty($fieldName)) {
			$this->setEntity($fieldName);
		}

		$this->unlockField($this->field());
		if (!is_array($options)) {
			$options = [];
		}
		$defaultOptions = $this->_getOptionsForElem('flag.defaultOpt');
		$options = $defaultOptions + $options;
		$divClass = 'form-group';
		$label = '';
		$list = [];
		$options = $this->_optionsOptions($options);
		if (isset($options['label'])) {
			$label = $this->label($fieldName, $options['label'], ['class' => 'control-label']);
		}
		if (isset($options['options'])) {
			$list = $options['options'];
		}
		$listExtraOptions = $this->_getOptionsForElem('flag.extraOpt');
		$this->_prepareExtraOptions($options, $listExtraOptions);
		$errors = FormHelper::error($fieldName, null, ['class' => 'help-block']);
		if (!empty($errors)) {
			$divClass .= ' has-error error';
		}
		$divOptions = [
			'id' => $this->domId($fieldName),
			'data-input-name' => $this->_name(null, $fieldName),
			'data-selected-country' => $this->value($fieldName),
		];
		$divOptionsDefault = $this->_getOptionsForElem('flag.divOpt');
		if (!empty($list)) {
			$divOptions['data-countries'] = json_encode($list);
		}
		foreach ($listExtraOptions as $extraOptionName) {
			if (isset($options['data-' . $extraOptionName])) {
				$divClass['data-' . $extraOptionName] = $options['data-' . $extraOptionName];
			}
		}
		$result = $this->Html->div($divClass, $label .
			$this->Html->div(null, '', $divOptions + $divOptionsDefault) . $errors);

		return $result;
	}
public function flag($fieldName, $options = []) {
		if (!empty($fieldName)) {
			$this->setEntity($fieldName);
		}

		$this->unlockField($this->field());
		if (!is_array($options)) {
			$options = [];
		}
		$defaultOptions = $this->_getOptionsForElem('flag.defaultOpt');
		$options = $defaultOptions + $options;
		$divClass = 'form-group';
		$label = '';
		$list = [];
		$options = $this->_optionsOptions($options);
		if (isset($options['label'])) {
			$label = $this->label($fieldName, $options['label'], ['class' => 'control-label']);
		}
		if (isset($options['options'])) {
			$list = $options['options'];
		}
		$listExtraOptions = $this->_getOptionsForElem('flag.extraOpt');
		$this->_prepareExtraOptions($options, $listExtraOptions);
		$errors = FormHelper::error($fieldName, null, ['class' => 'help-block']);
		if (!empty($errors)) {
			$divClass .= ' has-error error';
		}
		$divOptions = [
			'id' => $this->domId($fieldName),
			'data-input-name' => $this->_name(null, $fieldName),
			'data-selected-country' => $this->value($fieldName),
		];
		$divOptionsDefault = $this->_getOptionsForElem('flag.divOpt');
		if (!empty($list)) {
			$divOptions['data-countries'] = json_encode($list);
		}
		foreach ($listExtraOptions as $extraOptionName) {
			if (isset($options['data-' . $extraOptionName])) {
				$divClass['data-' . $extraOptionName] = $options['data-' . $extraOptionName];
			}
		}
		$result = $this->Html->div($divClass, $label .
			$this->Html->div(null, '', $divOptions + $divOptionsDefault) . $errors);

		return $result;
	}
public function flag ( $ fieldName , $ options = [ ] ) { if ( ! empty ( $ fieldName ) ) { $ this -> setEntity ( $ fieldName ) ; } $ this -> unlockField ( $ this -> field ( ) ) ; if ( ! is_array ( $ options ) ) { $ options = [ ] ; } $ defaultOptions = $ this -> _getOptionsForElem ( 'flag.defaultOpt' ) ; $ options = $ defaultOptions + $ options ; $ divClass = 'form-group' ; $ label = '' ; $ list = [ ] ; $ options = $ this -> _optionsOptions ( $ options ) ; if ( isset ( $ options [ 'label' ] ) ) { $ label = $ this -> label ( $ fieldName , $ options [ 'label' ] , [ 'class' => 'control-label' ] ) ; } if ( isset ( $ options [ 'options' ] ) ) { $ list = $ options [ 'options' ] ; } $ listExtraOptions = $ this -> _getOptionsForElem ( 'flag.extraOpt' ) ; $ this -> _prepareExtraOptions ( $ options , $ listExtraOptions ) ; $ errors = FormHelper :: error ( $ fieldName , null , [ 'class' => 'help-block' ] ) ; if ( ! empty ( $ errors ) ) { $ divClass .= ' has-error error' ; } $ divOptions = [ 'id' => $ this -> domId ( $ fieldName ) , 'data-input-name' => $ this -> _name ( null , $ fieldName ) , 'data-selected-country' => $ this -> value ( $ fieldName ) , ] ; $ divOptionsDefault = $ this -> _getOptionsForElem ( 'flag.divOpt' ) ; if ( ! empty ( $ list ) ) { $ divOptions [ 'data-countries' ] = json_encode ( $ list ) ; } foreach ( $ listExtraOptions as $ extraOptionName ) { if ( isset ( $ options [ 'data-' . $ extraOptionName ] ) ) { $ divClass [ 'data-' . $ extraOptionName ] = $ options [ 'data-' . $ extraOptionName ] ; } } $ result = $ this -> Html -> div ( $ divClass , $ label . $ this -> Html -> div ( null , '' , $ divOptions + $ divOptionsDefault ) . $ errors ) ; return $ result ; }
Creates a flagstrap input widget.

### Options:

- `options` - array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the
SELECT element.

@param string $fieldName Name of a field, like this "Modelname.fieldname"
@param array $options Array of HTML attributes.
@return string An HTML text input element.
@see {@link https://github.com/blazeworx/flagstrap} Flagstrap
Creates a flagstrap input widget .