本文整理匯總了PHP中Symfony\Component\Form\FormView::hasChildren方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormView::hasChildren方法的具體用法?PHP FormView::hasChildren怎麽用?PHP FormView::hasChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Form\FormView
的用法示例。
在下文中一共展示了FormView::hasChildren方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildViewBottomUp
/**
* Adds a CSRF field to the root form view.
*
* @param FormView $view The form view
* @param FormInterface $form The form
*/
public function buildViewBottomUp(FormView $view, FormInterface $form)
{
if (!$view->hasParent() && $view->hasChildren() && $form->hasAttribute('csrf_field_name')) {
$name = $form->getAttribute('csrf_field_name');
$csrfProvider = $form->getAttribute('csrf_provider');
$intention = $form->getAttribute('csrf_intention');
$factory = $form->getAttribute('csrf_factory');
$data = $csrfProvider->generateCsrfToken($intention);
$csrfForm = $factory->createNamed('hidden', $name, $data, array('property_path' => false));
$view->addChild($csrfForm->createView($view));
}
}
示例2: buildViewBottomUp
/**
* {@inheritdoc}
*/
public function buildViewBottomUp(FormView $view, FormInterface $form)
{
$view->set('widget', $form->getAttribute('widget'));
if ($view->hasChildren()) {
$pattern = $form->getAttribute('formatter')->getPattern();
// set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy)
// lookup various formats at http://userguide.icu-project.org/formatparse/datetime
if (preg_match('/^([yMd]+).+([yMd]+).+([yMd]+)$/', $pattern)) {
$pattern = preg_replace(array('/y+/', '/M+/', '/d+/'), array('{{ year }}', '{{ month }}', '{{ day }}'), $pattern);
} else {
// default fallback
$pattern = '{{ year }}-{{ month }}-{{ day }}';
}
$view->set('date_pattern', $pattern);
}
}
示例3: buildViewBottomUp
/**
* {@inheritdoc}
*/
public function buildViewBottomUp(FormView $view, FormInterface $form)
{
$view->set('widget', $form->getAttribute('widget'));
$pattern = $form->getAttribute('formatter')->getPattern();
$format = $pattern;
if ($view->hasChildren()) {
// set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy)
// lookup various formats at http://userguide.icu-project.org/formatparse/datetime
if (preg_match('/^([yMd]+).+([yMd]+).+([yMd]+)$/', $pattern)) {
$pattern = preg_replace(array('/y+/', '/M+/', '/d+/'), array('{{ year }}', '{{ month }}', '{{ day }}'), $pattern);
} else {
// default fallback
$pattern = '{{ year }}-{{ month }}-{{ day }}';
}
}
$view->set('date_pattern', $pattern);
$view->set('date_format', $this->convertJqueryDate($pattern));
$view->set('change_month', $form->getAttribute('changemonth'));
$view->set('change_year', $form->getAttribute('changeyear'));
$view->set('min_date', $form->getAttribute('mindate'));
$view->set('max_date', $form->getAttribute('maxdate'));
$view->set('buttonImage', $form->getAttribute('buttonImage'));
$view->set('locale', $this->session->getLocale());
}