baser/views/helpers/form_ex.php
/**
 * Generates a form input element complete with label and wrapper div
 *
 * Options - See each field type method for more information. Any options that are part of
 * $attributes or $options for the different type methods can be included in $options for input().
 *
 * - 'type' - Force the type of widget you want. e.g. ```type => 'select'```
 * - 'label' - control the label
 * - 'div' - control the wrapping div element
 * - 'options' - for widgets that take options e.g. radio, select
 * - 'error' - control the error message that is produced
 *
 * @param string $fieldName This should be "Modelname.fieldname"
 * @param array $options Each type of input takes different options.
 * @return string Completed form widget
 */
Generates a form input element complete with label and wrapper div
Options - See each field type method for more information. Any options that are part of
$attributes or $options for the different type methods can be included in $options for input().

- 'type' - Force the type of widget you want.

@param string $fieldName This should be "Modelname.fieldname"
@param array $options Each type of input takes different options.
@return string Completed form widget
Generates a form input element complete with label and wrapper div Options - See each field type method for more information . Any options that are part of $attributes or $options for the different type methods can be included in $options for input () . - ' type ' - Force the type of widget you want . @param string $fieldName This should be " Modelname . fieldname " @param array $options Each type of input takes different options . @return string Completed form widget
function input($fieldName, $options = array()) {
		$options = $this->executeHook('beforeFormInput', $fieldName, $options);
		$type = '';
		if(isset($options['type'])) {
			$type = $options['type'];
		}
		if(!isset($options['div'])) {
			$options['div'] = false;
		}
		if(!isset($options['error'])) {
			$options['error'] = false;
		}
		switch($type) {
			case 'text':
			default :
				if(!isset($options['label'])) {
					$options['label'] = false;
				}
				break;
			case 'radio':
				if(!isset($options['legend'])) {
					$options['legend'] = false;
				}
				if(!isset($options['separator'])) {
					$options['separator'] = '　';
				}
				break;
		}
		$out = parent::input($fieldName, $options);
		if(!empty($options['counter'])) {
			$domId = $this->domId($fieldName, $options);
			$counter = '<span id="'.$domId.'Counter'.'" class="size-counter"></span>';
			$script = '$("#'.$domId.'").keyup(countSize);$("#'.$domId.'").keyup();';
			if(!$this->sizeCounterFunctionLoaded) {
				$script .= <<< DOC_END
function countSize() {
	var len = $(this).val().length;
	var maxlen = $(this).attr('maxlength');
	if(!maxlen || maxlen == -1){
		maxlen = '-';
	}
	$("#"+$(this).attr('id')+'Counter').html(len+'/<small>'+maxlen+'</small>');
}
DOC_END;
				$this->sizeCounterFunctionLoaded = true;
			}
			$out = $out.$counter.$this->Javascript->codeBlock($script);
		}
		return $this->executeHook('afterFormInput', $fieldName, $out);
	}
function input ( $ fieldName , $ options = array ( ) ) { $ options = $ this -> executeHook ( 'beforeFormInput' , $ fieldName , $ options ) ; $ type = '' ; if ( isset ( $ options [ 'type' ] ) ) { $ type = $ options [ 'type' ] ; } if ( ! isset ( $ options [ 'div' ] ) ) { $ options [ 'div' ] = false ; } if ( ! isset ( $ options [ 'error' ] ) ) { $ options [ 'error' ] = false ; } switch ( $ type ) { case 'text' : default : if ( ! isset ( $ options [ 'label' ] ) ) { $ options [ 'label' ] = false ; } break ; case 'radio' : if ( ! isset ( $ options [ 'legend' ] ) ) { $ options [ 'legend' ] = false ; } if ( ! isset ( $ options [ 'separator' ] ) ) { $ options [ 'separator' ] = '　'; } break ; } $ out = parent :: input ( $ fieldName , $ options ) ; if ( ! empty ( $ options [ 'counter' ] ) ) { $ domId = $ this -> domId ( $ fieldName , $ options ) ; $ counter = '<span id="' . $ domId . 'Counter' . '" class="size-counter"></span>' ; $ script = '$("#' . $ domId . '").keyup(countSize);$("#' . $ domId . '").keyup();' ; if ( ! $ this -> sizeCounterFunctionLoaded ) { $ script .= <<<  DOC_END function countSize() { 	var len = $(this).val().length; 	var maxlen = $(this).attr('maxlength'); 	if(!maxlen || maxlen == -1){ 		maxlen = '-'; 	} 	$("#"+$(this).attr('id')+'Counter').html(len+'/<small>'+maxlen+'</small>'); } 
DOC_END ; $ this -> sizeCounterFunctionLoaded = true ; } $ out = $ out . $ counter . $ this -> Javascript -> codeBlock ( $ script ) ; } return $ this -> executeHook ( 'afterFormInput' , $ fieldName , $ out ) ; }
Generates a form input element complete with label and wrapper div
 Options - See each field type method for more information.
Generates a form input element complete with label and wrapper div Options - See each field type method for more information .
/* カウンター */