Skip to content

Instantly share code, notes, and snippets.

@thrashr888
Created July 15, 2009 06:16
Show Gist options
  • Save thrashr888/147513 to your computer and use it in GitHub Desktop.
Save thrashr888/147513 to your computer and use it in GitHub Desktop.
<?php
/**
* Define error
*
* @author Dmitry Nesteruk, Andrey Kotlyarov
* @param string $fieldName
* @param string $message
* @return void
*/
public function defineError($fieldName, $message)
{
$checkName = 'check_define_'.md5($fieldName);
$this->getErrorSchema()->getValidator()->addOption($checkName);
$this->getErrorSchema()->getValidator()->addMessage($checkName, $message);
$this->getErrorSchema()->addError(
new sfValidatorError(
$this->getErrorSchema()->getValidator(),
$checkName,
array(
'value' => sfContext::getInstance()->getRequest()->getParameter($fieldName),
$checkName => $this->getErrorSchema()->getValidator($checkName)
)
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment