本文整理汇总了PHP中Venne\Forms\Form::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addError方法的具体用法?PHP Form::addError怎么用?PHP Form::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Venne\Forms\Form
的用法示例。
在下文中一共展示了Form::addError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleCatchError
public function handleCatchError(Form $form, $e)
{
if ($e instanceof InvalidArgumentException) {
$form->addError($e->getMessage());
return TRUE;
} else {
if ($e instanceof DBALException && strpos($e->getMessage(), 'Duplicate entry') !== false) {
$form->addError('Duplicate entry');
return TRUE;
}
}
}
示例2: handleSave
public function handleSave(Form $form)
{
$values = $form->values;
if ($values['file']->isOk()) {
if ($values['cleanout']) {
foreach ($this->userRepository->findAll() as $user) {
$this->userRepository->delete($user);
}
}
/** @var FileUpload $file */
$file = $values['file'];
$data = file_get_contents($file->getTemporaryFile());
foreach (explode("\n", $data) as $row) {
if (!$row) {
continue;
}
$items = explode(',', $row);
if (!count($items)) {
continue;
}
try {
$user = new UserEntity(trim($items[0]));
} catch (InvalidArgumentException $e) {
$form->addError($e->getMessage());
}
$this->userRepository->save($user);
}
}
}
示例3: handleCatchError
public function handleCatchError(Form $form, $e)
{
if ($e instanceof DBALException && $e->getCode() == '23000') {
$form->addError('User is not unique');
return TRUE;
}
}
示例4: handleCatchError
public function handleCatchError(Form $form, $e)
{
if ($e instanceof PermissionDeniedException) {
$form->addError('You have not writable permissions.');
return TRUE;
}
}
示例5: handleValidate
public function handleValidate(Form $form)
{
if (!isset($this->sessionSection->captcha) || $form['_captcha']->value != $this->sessionSection->captcha) {
$form->addError('Nesprávně opsaný obrázek, zkuste to prosím znovu');
$form['_captcha']->setOption('description', Html::el('img')->src($this->getCaptchaBuilder()->inline()));
}
}
示例6: handleSuccess
public function handleSuccess(Form $form)
{
$values = $form->getValues();
$oldPath = $this->moduleHelpers->expandPath($form->data, 'Resources/layouts');
$form->data = $this->getKeyByValues($values);
$path = $this->moduleHelpers->expandPath($form->data, 'Resources/layouts');
umask(00);
if (!file_exists(dirname($path))) {
if (!@mkdir(dirname($path), 0777, TRUE)) {
$form->addError("File '{$path}' is not writable.");
}
}
file_put_contents($path, $values['text']);
if ($oldPath && $oldPath !== $path) {
@unlink($oldPath);
}
}
示例7: handleCatchError
public function handleCatchError(Form $form, $e)
{
$m = explode("'", $e->getMessage());
$form->addError("Duplicate entry '{$m[1]}'");
return true;
}
示例8: handleSuccess
public function handleSuccess(Form $form)
{
if ($form->isSubmitted() === $form->getSaveButton()) {
$values = $form->values;
if ($values['type'] == 'component') {
$file = $this->getFileByClass($values['component']);
$baseName = $file->getBasename('.php') . '.latte';
$template = $file->getPath() . '/' . $baseName;
$target = $this->moduleHelpers->expandPath('@' . $values['target'] . 'Module', 'Resources/layouts');
if ($values['layout']) {
$target .= '/' . $values['layout'];
}
$target .= '/' . $baseName;
} else {
$presenter = explode(':', $values['presenter']);
$module = lcfirst($presenter[0]);
$page = lcfirst($presenter[2]);
$presenter = lcfirst($presenter[3]);
$template = $this->moduleHelpers->expandPath('@' . $module . 'Module/@' . $page . '.' . $presenter . '.latte', 'Resources/layouts');
$target = $this->moduleHelpers->expandPath('@' . $values['target'] . 'Module/' . ($values['layout'] ? $values['layout'] . '/' : '') . '@' . $page . '.' . $presenter . '.latte', 'Resources/layouts');
}
if (!copy($template, $target)) {
$form->addError("Unable to copy file '{$template}' to '{$target}'.");
}
}
}
示例9: handleCatchError
public function handleCatchError(Form $form, $e)
{
$form->addError($e->getMessage());
return true;
}