src/MvcCore/Ext/Form/AddMethods.php
public function AddError ($errorMsg, $fieldNames = NULL) {
		/** @var $this \MvcCore\Ext\Forms\IForm */
		$errorMsgUtf8 = iconv(
			mb_detect_encoding($errorMsg, mb_detect_order(), TRUE),
			"UTF-8",
			$errorMsg
		);
		$fieldNamesArr = $fieldNames === NULL ? [] : (gettype($fieldNames) == 'array' ? $fieldNames : [$fieldNames]);
		$newErrorRec = [strip_tags($errorMsgUtf8), $fieldNamesArr];
		if ($fieldNamesArr) {
			foreach ($fieldNamesArr as $fieldName) {
				if (isset($this->fields[$fieldName])) {
					$field = & $this->fields[$fieldName];
					$field
						->AddError($errorMsgUtf8)
						->AddCssClasses('error');
					if ($field instanceof \MvcCore\Ext\Forms\IFieldsGroup)
						$field->AddGroupLabelCssClasses('error');
				}
			}
		}
		$this->errors[] = $newErrorRec;
		$this->result = \MvcCore\Ext\Forms\IForm::RESULT_ERRORS;
		return $this;
	}
public function AddError ($errorMsg, $fieldNames = NULL) {
		/** @var $this \MvcCore\Ext\Forms\IForm */
		$errorMsgUtf8 = iconv(
			mb_detect_encoding($errorMsg, mb_detect_order(), TRUE),
			"UTF-8",
			$errorMsg
		);
		$fieldNamesArr = $fieldNames === NULL ? [] : (gettype($fieldNames) == 'array' ? $fieldNames : [$fieldNames]);
		$newErrorRec = [strip_tags($errorMsgUtf8), $fieldNamesArr];
		if ($fieldNamesArr) {
			foreach ($fieldNamesArr as $fieldName) {
				if (isset($this->fields[$fieldName])) {
					$field = & $this->fields[$fieldName];
					$field
						->AddError($errorMsgUtf8)
						->AddCssClasses('error');
					if ($field instanceof \MvcCore\Ext\Forms\IFieldsGroup)
						$field->AddGroupLabelCssClasses('error');
				}
			}
		}
		$this->errors[] = $newErrorRec;
		$this->result = \MvcCore\Ext\Forms\IForm::RESULT_ERRORS;
		return $this;
	}
public function AddError ( $ errorMsg , $ fieldNames = NULL ) { /** @var $this \MvcCore\Ext\Forms\IForm */ $ errorMsgUtf8 = iconv ( mb_detect_encoding ( $ errorMsg , mb_detect_order ( ) , TRUE ) , "UTF-8" , $ errorMsg ) ; $ fieldNamesArr = $ fieldNames === NULL ? [ ] : ( gettype ( $ fieldNames ) == 'array' ? $ fieldNames : [ $ fieldNames ] ) ; $ newErrorRec = [ strip_tags ( $ errorMsgUtf8 ) , $ fieldNamesArr ] ; if ( $ fieldNamesArr ) { foreach ( $ fieldNamesArr as $ fieldName ) { if ( isset ( $ this -> fields [ $ fieldName ] ) ) { $ field = & $ this -> fields [ $ fieldName ] ; $ field -> AddError ( $ errorMsgUtf8 ) -> AddCssClasses ( 'error' ) ; if ( $ field instanceof \ MvcCore \ Ext \ Forms \ IFieldsGroup ) $ field -> AddGroupLabelCssClasses ( 'error' ) ; } } } $ this -> errors [ ] = $ newErrorRec ; $ this -> result = \ MvcCore \ Ext \ Forms \ IForm :: RESULT_ERRORS ; return $ this ; }
Add form submit error and switch form result to zero - to error state.
@param string $errorMsg Any error message, translated if necessary. All html tags from error message will be removed automatically.
@param string|array|NULL $fieldNames Optional, field name string or array with field names where error happened.
@return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
Add form submit error and switch form result to zero - to error state .