TwbsMaxlength.php
public static function apply($field, $clientOptions, $render = true)
	{
		if ( isset($field->inputOptions['maxlength'])) {
			$maxLength = $field->inputOptions['maxlength'];
		} else {
			$maxLength = static::getMaxLength($field->model, Html::getAttributeName($field->attribute));
		}
		if ( ! empty($maxLength) ) {
			$field->inputOptions['maxlength'] = $maxLength;
			$id = Html::getInputId($field->model, $field->attribute);
			static::widget( [
				'selector' => '#'.$id,
				'clientOptions' => $clientOptions
			]);
		}
		if ( $render ) {
			echo $field;
		}
		return $field;
	}
public static function apply($field, $clientOptions, $render = true)
	{
		if ( isset($field->inputOptions['maxlength'])) {
			$maxLength = $field->inputOptions['maxlength'];
		} else {
			$maxLength = static::getMaxLength($field->model, Html::getAttributeName($field->attribute));
		}
		if ( ! empty($maxLength) ) {
			$field->inputOptions['maxlength'] = $maxLength;
			$id = Html::getInputId($field->model, $field->attribute);
			static::widget( [
				'selector' => '#'.$id,
				'clientOptions' => $clientOptions
			]);
		}
		if ( $render ) {
			echo $field;
		}
		return $field;
	}
public static function apply ( $ field , $ clientOptions , $ render = true ) { if ( isset ( $ field -> inputOptions [ 'maxlength' ] ) ) { $ maxLength = $ field -> inputOptions [ 'maxlength' ] ; } else { $ maxLength = static :: getMaxLength ( $ field -> model , Html :: getAttributeName ( $ field -> attribute ) ) ; } if ( ! empty ( $ maxLength ) ) { $ field -> inputOptions [ 'maxlength' ] = $ maxLength ; $ id = Html :: getInputId ( $ field -> model , $ field -> attribute ) ; static :: widget ( [ 'selector' => '#' . $ id , 'clientOptions' => $ clientOptions ] ) ; } if ( $ render ) { echo $ field ; } return $ field ; }
Add the maxlength attribute to an ActiveField.

The plugin requires that the max number of characters is specified as the HTML5 attribute "maxlength". This
method adds this attribute if it is not already defined into the HTML attributes of an ActiveField. The
value is retrieved from the StringValidator settings that is attached to the model attribute.
Note that if maxlength can't be defined, the plugin is not registred for the view.

Note that this method is deprecated and should be replaced by ActiveField widget initialization
as explained in the README file.

@deprecated since Yii2 2.0.3 it is possible to set the maxlength HTML attribute of a text input
[Read more](http://www.yiiframework.com/doc-2.0/yii-widgets-activefield.html#textInput%28%29-detail)

@param yii\widgets\ActiveField $field
@param array $clientOptions Bootstrap maxlength plugin options
@param boolean $render when true, the $field is output
@return yii\widgets\ActiveField the field containing the "maxlength" option (if it could be obtained)
Add the maxlength attribute to an ActiveField .