本文整理汇总了PHP中sfForm::hasGlobalErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::hasGlobalErrors方法的具体用法?PHP sfForm::hasGlobalErrors怎么用?PHP sfForm::hasGlobalErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::hasGlobalErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertFormError
/**
* Assert form error
*
* @param sfForm $form
* @param string $field - Form field name
* @param string $expectedError - Expected error, "required"
* @param string $message
*/
protected function assertFormError(sfForm $form, $field, $expectedError, $message = null)
{
$message = $message ? $message . PHP_EOL : null;
// Global error
if (!$field) {
$this->assertTrue($form->hasGlobalErrors(), $this->makeErrorMess($form, $message . "Expected form HAS global errors"));
$errors = implode('; ', $form->getGlobalErrors());
$this->assertContains($expectedError, $errors, $this->makeErrorMess($form, $message . "Global errors contains next text"));
} else {
$errors = $form->getErrorSchema();
$this->assertTrue(isset($errors[$field]), $this->makeErrorMess($form, $message . "Expected field `{$field}` HAS error"));
$error = $errors[$field]->getCode();
$this->assertEquals($expectedError, $error, $this->makeErrorMess($form, $message . "Expected error `{$expectedError}` for field `{$field}`"));
}
}
示例2: hasGlobalErrors
/**
* Treats any error as a global error, so we can show these errors in the global area.
* @see sfForm::hasGlobalErrors()
*
* @return Boolean
*/
public function hasGlobalErrors()
{
$hasGlobalErrors = parent::hasGlobalErrors();
return TwicalHelper::hasGlobalErrors($hasGlobalErrors, $this);
}