本文整理汇总了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);
}
示例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;
}
示例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);
}
}
}
示例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);
}