Ejemplo n.º 1
0
	/**
	 * @param $model - profile model
	 * @param $field - profile fields model item
	 * @param $params - htmlOptions
	 * @return string
	 */
	public function editAttribute($model,$field,$htmlOptions=array()) {
		if (!isset($htmlOptions['size'])) $htmlOptions['size'] = 60;
		if (!isset($htmlOptions['maxlength'])) $htmlOptions['maxlength'] = (($field->field_size)?$field->field_size:10);
		if (!isset($htmlOptions['id'])) $htmlOptions['id'] = get_class($model).'_'.$field->varname;
		
		$id = $htmlOptions['id'];
		$options['dateFormat'] = 'yy-mm-dd';
		$options=CJavaScript::encode($options);
		
		$basePath=Yii::getPathOfAlias('application.modules.user.views.asset');
		$baseUrl=Yii::app()->getAssetManager()->publish($basePath);
		$cs = Yi::clientScript()
			->registerCssFile($baseUrl.'/css/'.$this->params['ui-theme'].'/jquery-ui.css')
			->registerScriptFile($baseUrl.'/js/jquery-ui.min.js');
		
		$language = $this->params['language'];
		if ($language!='en') {
			$js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$language}'], {$options}));";
			$cs->registerScriptFile($baseUrl.'/js/jquery-ui-i18n.min.js');
		} else $js = "jQuery('#{$id}').datepicker({$options});";

		$cs->registerScript('ProfileFieldController'.'#'.$id, $js);
		
		return CHtml::activeTextField($model,$field->varname,$htmlOptions);
	}