本文整理汇总了PHP中Widget::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::addError方法的具体用法?PHP Widget::addError怎么用?PHP Widget::addError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::addError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: positiveFloatRegExpHook
public function positiveFloatRegExpHook($strRegexp, $varValue, \Widget $objWidget)
{
if ($strRegexp == 'posfloat') {
if (strpos($varValue, ',') != false) {
$objWidget->addError($GLOBALS['TL_LANG']['ERR']['posFloat']['commaFound']);
}
if (!preg_match('/^\\d+(?:\\.\\d+)?$/', $varValue)) {
$objWidget->addError($GLOBALS['TL_LANG']['ERR']['posFloat']['noFloat']);
}
return true;
}
return false;
}
示例2: hookAddCustomRegexp
/**
* Add the custom regexp "dezimal" to Contao.
*/
public function hookAddCustomRegexp($strRegexp, $varValue, \Widget $objWidget)
{
if ($strRegexp == 'dezimal') {
if (!preg_match('/^\\-?\\d+(,\\d+)?$/', trim($varValue))) {
$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['digit'], $objWidget->label));
}
return true;
}
return false;
}
示例3: validateVotingEmailFormField
public function validateVotingEmailFormField(\Widget $objWidget, $intId)
{
if (($objForm = \FormModel::findBy('alias', str_replace('auto_', '', $intId))) !== null && $objForm->maxVoteCount) {
// check if a voting from the mail address already exists
$db = \Database::getInstance();
$objEmailCheck = $db->prepare('SELECT * FROM tl_formdata_details fdt INNER JOIN tl_formdata fd ON fdt.pid=fd.id INNER JOIN tl_form f ON fd.form=f.title WHERE fdt.ff_name=? AND fdt.value=? AND f.alias=?')->execute('email', $objWidget->value, $objForm->alias);
if ($objEmailCheck->numRows > 0 && $objEmailCheck->numRows >= $objForm->maxVoteCount) {
$objWidget->addError(sprintf($GLOBALS['TL_LANG']['email_voting']['maxVoteCount'], $objForm->maxVoteCount));
}
}
return $objWidget;
}
示例4: validateRegexp
/**
* Validate a custom regular expression
* @param string
* @param mixed
* @param object
* @return boolean
*/
public function validateRegexp($strRegexp, $varValue, Widget $objWidget)
{
switch ($strRegexp) {
case 'price':
if (!preg_match('/^[\\d \\.-]*$/', $varValue)) {
$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['digit'], $objWidget->label));
}
return true;
break;
case 'discount':
if (!preg_match('/^[-+]\\d+(\\.\\d{1,2})?%?$/', $varValue)) {
$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['discount'], $objWidget->label));
}
return true;
break;
case 'surcharge':
if (!preg_match('/^-?\\d+(\\.\\d{1,2})?%?$/', $varValue)) {
$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['surcharge'], $objWidget->label));
}
return true;
break;
}
return false;
}
示例5: doCheckForDoubleReviews
protected static function doCheckForDoubleReviews(\Widget $objWidget, $varValue, $strTable)
{
if ($strTable == 'tl_competition_review' && ($objReview = ReviewModel::findByPk(\Input::get('id'))) !== null) {
$objReviews = \HeimrichHannot\Competition\ReviewModel::findOneBy(array('sid=?', 'jid=?', 'tl_competition_review.id!=?'), array($varValue, $objReview->jid, \Input::get('id')));
// check for already existing reviews by the member for the current submission
if ($objReviews !== null) {
$objWidget->addError($GLOBALS['TL_LANG']['MSC']['reviewAlreadyExisting']);
}
}
}
示例6: handleSaveCallback
/**
* Handle the onsave_callback for a widget.
*
* @param array $field The field DCA.
*
* @param \Widget $widget The widget to validate.
*
* @param mixed $value The value.
*
* @return mixed
*/
protected function handleSaveCallback($field, $widget, $value)
{
$newValue = $value;
if (is_array($field['save_callback'])) {
foreach ($field['save_callback'] as $callback) {
$this->import($callback[0]);
try {
$newValue = $this->{$callback}[0]->{$callback}[1]($newValue, $this);
} catch (\Exception $e) {
$widget->addError($e->getMessage());
$this->blnSubmitInput = false;
return $value;
}
}
}
return $newValue;
}
示例7: customRegexp
/**
* Check for customer regular expression
*
* @param string $strRegexp
*
* @param string $varValue
*
* @param Widget $objWidget
*
* @return boolean
*/
public function customRegexp($strRegexp, $varValue, Widget $objWidget)
{
switch ($strRegexp) {
case 'colorRgb':
if (!preg_match('/^([0-9a-f]{3}|[0-9a-f]{6})$/i', $varValue)) {
$objWidget->addError('Field ' . $objWidget->label . ' should be a color RGB code.');
}
return true;
break;
}
return false;
}