本文整理汇总了PHP中Symfony\Component\Form\FormInterface::hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::hasAttribute方法的具体用法?PHP FormInterface::hasAttribute怎么用?PHP FormInterface::hasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::hasAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildViewBottomUp
/**
* Removes CSRF fields from all the form views except the root one.
*
* @param FormView $view The form view
* @param FormInterface $form The form
*/
public function buildViewBottomUp(FormView $view, FormInterface $form)
{
if ($view->hasParent() && $form->hasAttribute('csrf_field_name')) {
$name = $form->getAttribute('csrf_field_name');
if (isset($view[$name])) {
unset($view[$name]);
}
}
}
示例2: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form)
{
$view
->set('allow_add', $form->getAttribute('allow_add'))
->set('allow_delete', $form->getAttribute('allow_delete'))
;
if ($form->hasAttribute('prototype')) {
$view->set('prototype', $form->getAttribute('prototype'));
}
}
示例3: 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() && !$form->getAttribute('single_control') && $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));
}
}
示例4: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
{
$datas = json_decode($form->getClientData(), true);
$value = '';
if (false === empty($datas)) {
if (true === $form->getAttribute('multiple')) {
foreach ($datas as $data) {
$value .= $data['label'] . ', ';
}
} else {
$value = $datas['label'];
}
}
$view->set('tokeninput_value', $value)->set('route_name', $form->getAttribute('route_name'));
foreach ($this->_availableTokeninputOptions as $option) {
if ($form->hasAttribute($option)) {
$view->set($option, $form->getAttribute($option));
}
}
}
示例5: getFormValidationGroups
protected static function getFormValidationGroups(FormInterface $form)
{
$groups = null;
if ($form->hasAttribute('validation_groups')) {
$groups = $form->getAttribute('validation_groups');
if (is_callable($groups)) {
$groups = (array) call_user_func($groups, $form);
}
}
$currentForm = $form;
while (!$groups && $currentForm->hasParent()) {
$currentForm = $currentForm->getParent();
if ($currentForm->hasAttribute('validation_groups')) {
$groups = $currentForm->getAttribute('validation_groups');
if (is_callable($groups)) {
$groups = (array) call_user_func($groups, $currentForm);
}
}
}
if (null === $groups) {
$groups = array('Default');
}
return (array) $groups;
}
示例6: buildViewBottomUp
/**
* {@inheritdoc}
*/
public function buildViewBottomUp(FormView $view, FormInterface $form)
{
if ($form->hasAttribute('prototype') && $view->get('prototype')->get('multipart')) {
$view->set('multipart', true);
}
}