本文整理汇总了PHP中Symfony\Component\Form\FormBuilderInterface::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilderInterface::getAttribute方法的具体用法?PHP FormBuilderInterface::getAttribute怎么用?PHP FormBuilderInterface::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilderInterface
的用法示例。
在下文中一共展示了FormBuilderInterface::getAttribute方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
if (null !== ($prototypeFormBuilder = $builder->getAttribute('prototype'))) {
/** @var $prototypeFormBuilder FormBuilderInterface */
$prototypeFormBuilder->setData($options['prototype_data']);
}
}
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAttribute('enable', $options['enable']);
if ($builder->getAttribute('enable')) {
$builder->setAttribute('instance', $options['instance']);
}
$builder->setAttribute('homeFolder', $options['homeFolder']);
}
示例3: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$attr = $builder->getAttribute('sonata_admin');
if (isset($attr['class'])) {
$attr['class'] .= ' money';
$builder->setAttribute('sonata_admin', $attr);
}
$builder->addViewTransformer(new MoneyToLocalizedStringTransformer($options['precision'], $options['grouping'], null, $options['divisor']));
}
示例4: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$attr = $builder->getAttribute('sonata_admin');
if (isset($attr['class'])) {
$attr['class'] .= ' percent';
$builder->setAttribute('sonata_admin', $attr);
}
$builder->addViewTransformer(new PercentToLocalizedStringTransformer($options['precision'], $options['type']));
}
示例5: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$attr = $builder->getAttribute('sonata_admin');
if (isset($attr['class'])) {
$attr['class'] .= ' number';
$builder->setAttribute('sonata_admin', $attr);
}
$builder->addViewTransformer(new NumberToLocalizedStringTransformer($options['precision'], $options['grouping'], $options['rounding_mode']));
}
示例6: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAttribute('enable', $options['enable']);
if ($builder->getAttribute('enable')) {
$builder->setAttribute('base_path', $options['base_path']);
$builder->setAttribute('js_path', $options['js_path']);
$builder->setAttribute('inline', $options['inline']);
$builder->setAttribute('instance', $options['instance']);
}
}
示例7: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAttribute('include_variants', $options['include_variants']);
$builder->add('inventoryItems', InventoryItemCollectionType::NAME);
if ($builder->getAttribute('include_variants')) {
$builder->add('variant', VariantInventoryType::NAME);
}
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
/** @var Product $data */
$data = $event->getData();
/*
* If product has variant, product itself is removed from collection of variant products.
*/
if ($data && ($variant = $data->getVariant())) {
$variant->getProducts()->removeElement($data);
}
});
}
示例8: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAttribute('enable', $options['enable']);
if ($builder->getAttribute('enable')) {
$builder->setAttribute('base_path', $options['base_path']);
$configs = $this->container->getParameter('bootstrapp.ckeditor.configs');
$config = $options['config'];
$configName = $options['config_name'];
if (null === $configName) {
$configName = uniqid('bootstrapp', true);
}
if (array_key_exists($configName, $config)) {
$configs[$configName] = array_merge($configs[$configName], $config);
} else {
$configs[$configName] = $config;
}
$builder->setAttribute('config', $configs[$configName]);
$builder->setAttribute('plugins', $options['plugins']);
}
}
示例9: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAttribute('enable', $options['enable']);
if ($builder->getAttribute('enable')) {
$builder->setAttribute('autoload', $options['autoload']);
$builder->setAttribute('inline', $options['inline']);
$builder->setAttribute('jquery', $options['jquery']);
$builder->setAttribute('input_sync', $options['input_sync']);
$builder->setAttribute('base_path', $options['base_path']);
$builder->setAttribute('js_path', $options['js_path']);
$builder->setAttribute('jquery_path', $options['jquery_path']);
$configManager = clone $this->configManager;
$pluginManager = clone $this->pluginManager;
$stylesSetManager = clone $this->stylesSetManager;
$templateManager = clone $this->templateManager;
$config = $options['config'];
if ($options['config_name'] === null) {
$options['config_name'] = uniqid('ivory', true);
$configManager->setConfig($options['config_name'], $config);
} else {
$configManager->mergeConfig($options['config_name'], $config);
}
$pluginManager->setPlugins($options['plugins']);
$stylesSetManager->setStylesSets($options['styles']);
$templateManager->setTemplates($options['templates']);
$builder->setAttribute('config', $configManager->getConfig($options['config_name']));
$builder->setAttribute('plugins', $pluginManager->getPlugins());
$builder->setAttribute('styles', $stylesSetManager->getStylesSets());
$builder->setAttribute('templates', $templateManager->getTemplates());
}
}
示例10: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAttribute('enable', $options['enable']);
if ($builder->getAttribute('enable')) {
$builder->setAttribute('base_path', $options['base_path']);
$builder->setAttribute('js_path', $options['js_path']);
$config = $options['config'];
if ($options['config_name'] === null) {
$name = uniqid('ivory', true);
$options['config_name'] = $name;
$this->configManager->setConfig($name, $config);
} else {
$this->configManager->mergeConfig($options['config_name'], $config);
}
$this->pluginManager->setPlugins($options['plugins']);
$this->stylesSetManager->setStylesSets($options['styles']);
$this->templateManager->setTemplates($options['templates']);
$builder->setAttribute('config', $this->configManager->getConfig($options['config_name']));
$builder->setAttribute('plugins', $this->pluginManager->getPlugins());
$builder->setAttribute('styles', $this->stylesSetManager->getStylesSets());
$builder->setAttribute('templates', $this->templateManager->getTemplates());
}
}
示例11: getUserAwareChoiceBuilder
/**
* @param FormBuilderInterface $builder
* @param UserInterface|null $user
*
* @return callable
*/
public static function getUserAwareChoiceBuilder(FormBuilderInterface $builder, UserInterface $user = null)
{
return function (EntityRepository $objectRepository) use($builder, $user) {
return $objectRepository->createQueryBuilder('o')->andWhere('o.user = :user')->setParameter('user', $user ?: $builder->getAttribute('user_aware'));
};
}