本文整理汇总了PHP中sfValidatorBase::getFields方法的典型用法代码示例。如果您正苦于以下问题:PHP sfValidatorBase::getFields方法的具体用法?PHP sfValidatorBase::getFields怎么用?PHP sfValidatorBase::getFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfValidatorBase
的用法示例。
在下文中一共展示了sfValidatorBase::getFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseMessageVal
/**
* Parse message value
*
* @param string $key
* @param sfValidatorBase $objField
*
* @return string
*/
private function parseMessageVal($key, sfValidatorBase $objField)
{
if ($objField instanceof sfValidatorSchema) {
$retrunVal = '';
foreach ($objField->getFields() as $subKey => $subObjField) {
$retrunVal .= $this->parseMessageVal($subKey, $subObjField);
}
return $retrunVal;
}
$field_options = $objField->getOptions();
$messages = $objField->getMessages();
$val = "";
// if the field options for this item is empty, don't include it
if (empty($field_options[$key])) return "";
// var_dump(get_class($objField));
// var_dump($field_options);
if (is_array($field_options[$key])) {
// TODO sfValidatorBoolean
// foreach ($field_options[$key] as $key => $val) {
// if (empty($val)) {
// continue;
// } else {
// var_dump($val);die('OK');
// }
// }
return "";
}
if(!(isset($messages[$key]) || isset($messages[$this->parseMessageKey($key, $objField)]))) return "";
// find the actual error message
$mapped_key = $this->parseMessageKey($key, $objField);
if(isset($messages[$key]))
{
$val = $messages[$key];
}
else if(isset($messages[$mapped_key]))
{
$val = $messages[$mapped_key];
}
else
{
return;
}
// add slashes to ensure correct json output
$val = addslashes($val);
// replace any placeholder values
// this is a nasty hack (see line 88 for the matching hackery)
if(strpos($val, '%value%') !== false)
{
$val = '[[{ return \'' . str_replace('%value%', "' + $(elem).val() + '", $val) . '\';}]]';
}
if(strpos($val, '%min_length%') !== false)
{
$val = str_replace('%min_length%', $field_options['min_length'], $val);
}
if(strpos($val, '%max_length%') !== false)
{
$val = str_replace('%max_length%', $field_options['max_length'], $val);
}
return $val;
}