本文整理汇总了PHP中Symfony\Component\Form\Form::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::count方法的具体用法?PHP Form::count怎么用?PHP Form::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\Form
的用法示例。
在下文中一共展示了Form::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormErrorMessages
public function getFormErrorMessages(\Symfony\Component\Form\Form $form)
{
$errors = array();
$formErrors = iterator_to_array($form->getErrors(false, true));
foreach ($formErrors as $key => $error) {
$template = $error->getMessageTemplate();
$parameters = $error->getMessageParameters();
foreach ($parameters as $var => $value) {
$template = str_replace($var, $value, $template);
}
$errors[$key] = $template;
}
if ($form->count()) {
foreach ($form as $child) {
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getFormErrorMessages($child);
}
}
}
return $errors;
}
示例2: getFormErrors
public function getFormErrors(\Symfony\Component\Form\Form $form)
{
$errors = array();
if ($form->count() > 0) {
foreach ($form->all() as $child) {
/**
* @var \Symfony\Component\Form\Form $child
*/
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getFormErrors($child);
}
}
} else {
/**
* @var \Symfony\Component\Form\FormError $error
*/
foreach ($form->getErrors() as $key => $error) {
$errors[] = $error->getMessage();
}
}
return $errors;
}
示例3: getErrorMessages
private function getErrorMessages(Form $form)
{
$errors = array();
foreach ($form->getErrors() as $key => $error) {
$template = $error->getMessageTemplate();
$parameters = $error->getMessageParameters();
foreach ($parameters as $var => $value) {
$template = str_replace($var, $value, $template);
}
$errors[$key] = $template;
}
if ($form->count()) {
foreach ($form as $child) {
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getErrorMessages($child);
}
}
}
return $errors;
}
示例4: getErrorMessages
/**
* Collects error messages from a symfony form object
*
* @param \Symfony\Component\Form\Form $form
* @return array An array containing form error messages
*/
public static function getErrorMessages(\Symfony\Component\Form\Form $form, $i = null)
{
$errors = array();
if (null === $i) {
$i = 0;
}
foreach ($form->getErrors() as $error) {
$template = $error->getMessageTemplate();
$parameters = $error->getMessageParameters();
foreach ($parameters as $var => $value) {
$template = str_replace($var, $value, $template);
}
$errors[$i] = $template;
$i++;
}
if ($form->count()) {
foreach ($form as $child) {
if (!$child->isValid()) {
$errors = array_merge($errors, self::getErrorMessages($child, $i));
}
}
}
return $errors;
}
示例5: getErrorMessages
/**
* Generate a simpler validation error structure.
*
* @param \Symfony\Component\Form\Form $form
* @return type
*/
private function getErrorMessages(\Symfony\Component\Form\Form $form)
{
$errors = array();
foreach ($form->getErrors() as $key => $error) {
$errors[$key] = $error->getMessage();
}
if ($form->count()) {
foreach ($form->all() as $child) {
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getErrorMessages($child);
}
}
}
return $errors;
}