/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->phpEngine = new PhpEngine(new TemplateNameParser(), new FilesystemLoader(__DIR__ . '/../../Resources/views/Form/%name%')); $this->formHelperMock = $this->getMockBuilder('Symfony\\Bundle\\FrameworkBundle\\Templating\\Helper\\FormHelper')->disableOriginalConstructor()->getMock(); $this->formHelperMock->expects($this->any())->method('getName')->will($this->returnValue('form')); $this->phpEngine->addHelpers(array($this->formHelperMock, new CKEditorHelper($this->containerMock))); }
public function getFormErrorMessagesWithLabels(Form $form, FormHelper $formHelper) { $errors = array(); foreach ($form->getErrors() as $key => $error) { if ($form->isRoot()) { $errors['#'][] = $error->getMessage(); } else { $errors[] = $error->getMessage(); } } foreach ($form->all() as $child) { if (!$child->isValid()) { $label = $child->getConfig()->getOption('label'); if (!$label) { $label = $formHelper->humanize($child->getName()); } $errors[$label] = $this->getFormErrorMessagesWithLabels($child, $formHelper); } } return $errors; }
/** * @param array $params * @param Smarty_Internal_Template $smartyTemplate * @author Martin Schindler * @return string */ public function formErrors(array $params, Smarty_Internal_Template $smartyTemplate) { return $this->formHelper->errors($params['form']); }
/** * @param $form FormView * @param FormHelper $formHelper */ public function context_collection_row($form, $formHelper) { if ($form->count()) { echo $formHelper->label($form); } echo $formHelper->errors($form); echo $formHelper->widget($form); echo $formHelper->rest($form); }