本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::getOption方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getOption方法的具体用法?PHP FormBuilder::getOption怎么用?PHP FormBuilder::getOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getOption方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function it_builds_attribute_types_prototype_and_passes_it_as_argument(FormBuilder $builder, FormBuilder $fieldBuilder, FormFactoryInterface $formFactory, ChoiceListInterface $choiceList, AttributeInterface $attribute)
{
$builder->getFormFactory()->willReturn($formFactory);
$builder->add('attribute', 'sylius_server_attribute_choice', Argument::any())->willReturn($builder);
$builder->addEventSubscriber(Argument::any())->willReturn($builder);
$attribute->getType()->willReturn('checkbox')->shouldBeCalled();
$attribute->getConfiguration()->willReturn(array('label' => 'sylius.form.attribute.server_attribute_value.value'))->shouldBeCalled();
$choiceList->getChoices()->willReturn(array($attribute));
$fieldBuilder->getOption('choice_list')->willReturn($choiceList);
$builder->get('attribute')->willReturn($fieldBuilder);
$builder->create('value', 'checkbox', array('label' => 'sylius.form.attribute.server_attribute_value.value'))->shouldBeCalled()->willReturn($fieldBuilder);
$fieldBuilder->getForm()->willReturn('Form for attribute');
$builder->setAttribute('prototypes', array(0 => 'Form for attribute'))->shouldBeCalled();
$this->buildForm($builder, array());
}
示例2: buildMediaType
/**
* {@inheritdoc}
*/
public function buildMediaType(FormBuilder $formBuilder)
{
$formBuilder->add('binaryContent', 'file');
if ($formBuilder->getOption('context') == 'api') {
$formBuilder->add('contentType');
}
}
示例3: buildMediaType
/**
* {@inheritdoc}
*/
public function buildMediaType(FormBuilder $formBuilder)
{
if ($formBuilder->getOption('context') == 'api') {
$formBuilder->add('binaryContent', 'file');
$formBuilder->add('contentType');
} else {
$formBuilder->add('binaryContent', 'file', array('required' => false, 'label' => 'widget_label_binary_content'));
}
}
示例4: buildMediaType
/**
* @param FormBuilder $formBuilder
*/
public function buildMediaType(FormBuilder $formBuilder)
{
if ($formBuilder->getOption('context') !== 'api') {
$formBuilder->add('binaryContent', FileType::class, array('required' => true, 'label' => false));
}
}
示例5: buildResetAction
/**
* @param FormBuilder $builder
*
* @throws \Exception
*/
protected function buildResetAction(FormBuilder $builder)
{
$action = $builder->getOption('action');
$defaults = ['form_type' => LinkType::class, 'label' => 'sidus.datagrid.reset.label', 'uri' => $action ?: '?', 'icon' => 'close'];
$options = array_merge($defaults, $this->getResetButton());
$type = $options['form_type'];
unset($options['form_type']);
$builder->add('filterResetButton', $type, $options);
}
示例6: getValue
/**
* Get type value from resource.
*
* @param $objectOrArray
* @param $propertyPath
* @param FormBuilder $formConfig
*
* @return array|string
*/
public function getValue($objectOrArray, $propertyPath, FormBuilder $formConfig)
{
if (!is_a($objectOrArray, 'EasyRdf\\Resource')) {
return $objectOrArray;
}
if (is_string($propertyPath)) {
$propertyPath = new PropertyPath($propertyPath);
} elseif (!$propertyPath instanceof PropertyPathInterface) {
throw new UnexpectedTypeException($propertyPath, 'string or Symfony\\Component\\PropertyAccess\\PropertyPathInterface');
}
$property = (string) $propertyPath;
$resources = null;
if ($formConfig->getOption('multiple')) {
$resources = $objectOrArray->all($property);
} elseif ($formConfig->getType()->getName() === 'collection') {
$resources = $objectOrArray->all($property);
} else {
$resources = $objectOrArray->get($property);
}
return $this->getLiteralValues($resources);
}