Author: Fabien Potencier (fabien.potencier@symfony-project.com)
Author: Bernhard Schussek (bernhard.schussek@symfony-project.com)
Inheritance: extends Symfony\Component\Templating\Helper\Helper
コード例 #1
0
ファイル: PhpTemplateTest.php プロジェクト: jul6art/vscms
 /**
  * {@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)));
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 /**
  * @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']);
 }
コード例 #4
0
ファイル: Templates.php プロジェクト: scottleedavis/hackazon
 /**
  * @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);
 }