Author: Fabien Potencier (fabien.potencier@symfony-project.com)
Author: Bernhard Schussek (bernhard.schussek@symfony-project.com)
Inheritance: extends Symfony\Component\Templating\Helper\Helper
Beispiel #1
0
 /**
  * {@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']);
 }
Beispiel #4
0
 /**
  * @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);
 }