本文整理汇总了PHP中sfForm::getValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::getValidator方法的具体用法?PHP sfForm::getValidator怎么用?PHP sfForm::getValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::getValidator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceValidators
public static function replaceValidators(sfForm $form)
{
foreach ($form->getWidgetSchema()->getFields() as $name => $widget) {
if ($widget instanceof mtWidgetFormInputDate) {
$form->setValidator($name, self::getDateValidator());
} elseif ($widget instanceof sfWidgetFormFilterDate) {
$form->getValidator($name)->setOption("from_date", self::getDateValidator(array("required" => false)));
$form->getValidator($name)->setOption("to_date", self::getDateValidator(array("required" => false)));
}
if ($name == "attachment") {
$form->setValidator($name, new sfValidatorFile(array("required" => false, "path" => sfConfig::get("sf_upload_dir"))));
} elseif ($name == "email") {
$form->setValidator($name, new sfValidatorEmail());
}
}
}
示例2: correctValidators
/**
* Replacing validators with their up-to-date equivalent from an embedded form.
*
* @param sfForm $form Form instance on which to replace validators
*
* @return sfValidatorSchema
*/
protected function correctValidators($form)
{
foreach ($form->getEmbeddedForms() as $field => $embed) {
if ($form->getValidator($field) instanceof sfValidatorSchema) {
foreach ($embed->getValidatorSchema()->getFields() as $name => $validator) {
if (!$form->getValidator($field)->offsetExists($name)) {
$embed->getValidatorSchema()->offsetUnset($name);
}
}
$form->setValidator($field, $this->correctValidators($embed));
}
}
return $form->getValidatorSchema();
}
开发者ID:AUTOPLANNING,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:21,代码来源:sfDoctrineDynamicFormRelations.class.php
示例3: getFormFieldContainerClass
public function getFormFieldContainerClass(sfForm $form, $name)
{
$class = array('form-element');
$attributes = array();
if (isset($form[$name]))
{
$widget = $form->getWidget($name);
$validator = $form->getValidator($name);
switch (true)
{
case $validator->getOption('required') === true:
$class[] = 'required';
break;
default:
$class[] = sfInflector::underscore(str_replace('sfWidgetForm', '', get_class($widget)));
break;
}
}
return implode(' ', $class);
}