當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormInterface::getChildren方法代碼示例

本文整理匯總了PHP中Symfony\Component\Form\FormInterface::getChildren方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormInterface::getChildren方法的具體用法?PHP FormInterface::getChildren怎麽用?PHP FormInterface::getChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Form\FormInterface的用法示例。


在下文中一共展示了FormInterface::getChildren方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $knockout['enabled'] = $form->getAttribute('knockout');
     if ($knockout['enabled'] === true) {
         $knockout['viewModel'] = array('name' => $form->getName(), 'fields' => $this->buildViewModelFields($form->getChildren()), 'bindings' => $this->buildViewModelBindings($form->getChildren()), 'collections' => $this->getCollections($form->getChildren(), $view));
     }
     $view->set('knockout', $knockout);
 }
開發者ID:rjmunro,項目名稱:KnockoutJSBundle,代碼行數:8,代碼來源:KnockoutExtension.php

示例2: getErrorMessages

 public static function getErrorMessages(FormInterface $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->hasChildren()) {
         foreach ($form->getChildren() as $child) {
             if (!$child->isValid()) {
                 $errors[$child->getName()] = self::getErrorMessages($child);
             }
         }
     }
     return $errors;
 }
開發者ID:nutrija,項目名稱:dsl-symfony,代碼行數:20,代碼來源:FormHelper.php

示例3: buildNamePathMapping

 private function buildNamePathMapping(FormInterface $form, array &$forms, $namePath = '')
 {
     $iterator = new VirtualFormAwareIterator($form->getChildren());
     $iterator = new \RecursiveIteratorIterator($iterator);
     foreach ($iterator as $child) {
         $nestedNamePath = $namePath . '.' . $child->getName();
         $forms[$nestedNamePath] = $child;
         if ($child->hasChildren()) {
             $this->buildNamePathMapping($child, $forms, $nestedNamePath);
         }
     }
 }
開發者ID:laiello,項目名稱:mediathequescrum,代碼行數:12,代碼來源:DelegatingValidator.php

示例4: getErrorsAsString

 /** End Garantie Entity **/
 protected function getErrorsAsString($fields, $class, $admin, \Symfony\Component\Form\FormInterface $form, $line, $level = 0, $field = '', $message = null)
 {
     $errors = array();
     if ($form->getErrors()) {
         $one_view = array();
         foreach ($form->getErrors() as $keys => $error) {
             if (!isset($one_view[$field][$line])) {
                 $one_view[$field][$line] = true;
                 $repeat = str_repeat(' ', $level);
                 $label = isset($fields[$field]) ? '(' . (\PHPExcel_Cell::stringFromColumnIndex($fields[$field]) . ':' . $line) . ') ' : '';
                 $data = $form->getViewData();
                 if (is_array($data)) {
                     $data = implode('-', $data);
                 }
                 if ($error->getMessageParameters()) {
                     $data = implode($error->getMessageParameters());
                 }
                 $errors[] = $repeat . 'VALUE : ' . $label . ($data ?: 'empty') . "\n";
                 $errors[] = $repeat . 'ERROR : ' . $error->getMessage() . "\n\n";
             }
         }
     }
     foreach ($form->getChildren() as $field => $child) {
         if ($field == 'client') {
             continue;
         }
         if ($err = $this->getErrorsAsString($fields, $class, $admin, $child, $line, $level + 4, $field, null)) {
             $errors[] = $admin->trans('form.' . $class . '.' . $field) . "\n";
             $errors[] = $err;
         }
     }
     if (!empty($message)) {
         $errors[] = $message;
     }
     return implode($errors);
 }
開發者ID:defan-marunchak,項目名稱:eurotax,代碼行數:37,代碼來源:ImportClientCommand.php


注:本文中的Symfony\Component\Form\FormInterface::getChildren方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。