本文整理汇总了PHP中Symfony\Component\Form\FormConfigInterface类的典型用法代码示例。如果您正苦于以下问题:PHP FormConfigInterface类的具体用法?PHP FormConfigInterface怎么用?PHP FormConfigInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormConfigInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertFormConfig
/**
* @param array $expectedConfig
* @param FormConfigInterface $actualConfig
*/
protected function assertFormConfig(array $expectedConfig, FormConfigInterface $actualConfig)
{
foreach ($expectedConfig as $key => $value) {
$this->assertTrue($actualConfig->hasOption($key));
$this->assertEquals($value, $actualConfig->getOption($key));
}
}
示例2:
function it_builds_view(FormConfigInterface $config, FormView $view, FormInterface $form, FormInterface $formTable, FormInterface $formUserRegistration)
{
$prototypes = ['dataFetchers' => ['user_registration' => $formUserRegistration], 'renderers' => ['table' => $formTable]];
$config->getAttribute('prototypes')->willReturn($prototypes);
$form->getConfig()->willReturn($config);
$formTable->createView($view)->shouldBeCalled();
$formUserRegistration->createView($view)->shouldBeCalled();
$this->buildView($view, $form, []);
}
示例3: processDateTime
private function processDateTime(FormView $view, FormConfigInterface $config, FormRuleContextBuilder $context)
{
if ($config->getOption('format') !== DateTimeType::HTML5_FORMAT) {
return;
}
$rules = new RuleCollection();
$rules->set('date', new TransformerRule('date', true, $this->getFormRuleMessage($config)));
$context->add($view, $rules);
}
示例4: getFormRuleMessage
protected function getFormRuleMessage(FormConfigInterface $config)
{
// Get correct error message if one is set.
if ($config->hasOption('invalid_message')) {
$params = $config->getOption('invalid_message_parameters');
return new RuleMessage($config->getOption('invalid_message'), is_array($params) ? $params : array());
}
return null;
}
示例5: __construct
public function __construct(FormConfigInterface $config)
{
if ($config->getCompound() && !$config->getDataMapper()) {
throw new LogicException('Compound forms need a data mapper');
}
if ($config->getInheritData()) {
$this->defaultDataSet = true;
}
$this->config = $config;
$this->children = new OrderedHashMap();
}
示例6: configure
/**
* {@inheritdoc}
*/
public function configure($name, array $options, array $metadata, FormConfigInterface $parentConfig)
{
// The implementation uses a FormTypeGuesserInterface instance in order
// to guess the "required" value from different sources (PHPdoc,
// validation or doctrine metadata, etc.)
$guessed = $this->guesser->guessRequired($parentConfig->getDataClass(), $name);
if (null !== $guessed) {
$options['required'] = $guessed->getValue();
}
return $options;
}
示例7: prepareOptions
/**
* Prepare form options from config
*
* @param FormConfigInterface $config
*
* @return $config
*/
protected function prepareOptions(FormConfigInterface $config)
{
$options = array('disabled' => true, 'read_only' => true);
if ($help = $config->getOption('help')) {
$options['help'] = $help;
}
if ($label = $config->getOption('label')) {
$options['label'] = $label;
}
if ($select2 = $config->getOption('select2')) {
$options['select2'] = $select2;
}
return $options;
}
示例8: configure
/**
* {@inheritdoc}
*/
public function configure($name, array $options, array $metadata, FormConfigInterface $parentConfig)
{
if (!isset($options['class'])) {
$guessedOptions = $this->guesser->guessType($parentConfig->getDataClass(), $name)->getOptions();
$options['class'] = $guessedOptions['class'];
$options['multiple'] = $guessedOptions['multiple'];
$options['em'] = $guessedOptions['em'];
}
if ($metadata['associationType'] & ClassMetadata::TO_MANY) {
$options['attr']['multiple'] = true;
}
// Supported associations are displayed using advanced JavaScript widgets
$options['attr']['data-widget'] = 'select2';
// Configure "placeholder" option for entity fields
if ($metadata['associationType'] & ClassMetadata::TO_ONE && !isset($options[$placeHolderOptionName = $this->getPlaceholderOptionName()]) && false === $options['required']) {
$options[$placeHolderOptionName] = 'form.label.empty_value';
}
return $options;
}
示例9: getFilterTypeName
/**
* Get filter type name by form config
*
* @param FormConfigInterface $config
*
* @return string
*
* @deprecated Deprecated since version 2.0, to be removed in 2.1. Use EventDispatcher instead.
*/
protected function getFilterTypeName(FormConfigInterface $config)
{
$formType = $config->getType()->getInnerType();
return $config->hasAttribute('apply_filter') && is_string($config->getAttribute('apply_filter')) ? $config->getAttribute('apply_filter') : $formType->getName();
}
示例10: getFormRuleMessage
protected function getFormRuleMessage(FormConfigInterface $config)
{
// Get correct error message if one is set.
if ($config->hasOption('invalid_message')) {
// TODO support invalid_message_parameters
return new RuleMessage($config->getOption('invalid_message'));
}
return null;
}
示例11: validateChoiceLoaderForDefaultOptions
protected function validateChoiceLoaderForDefaultOptions(FormConfigInterface $config)
{
$this->assertNull($config->getOption('choice_loader'));
}
示例12: __construct
/**
* Creates an unmodifiable copy of a given configuration.
*
* @param FormConfigInterface $config The configuration to copy.
*/
public function __construct(FormConfigInterface $config)
{
$dispatcher = $config->getEventDispatcher();
if (!$dispatcher instanceof UnmodifiableEventDispatcher) {
$dispatcher = new UnmodifiableEventDispatcher($dispatcher);
}
$this->dispatcher = $dispatcher;
$this->name = $config->getName();
$this->propertyPath = $config->getPropertyPath();
$this->mapped = $config->getMapped();
$this->byReference = $config->getByReference();
$this->virtual = $config->getVirtual();
$this->compound = $config->getCompound();
$this->types = $config->getTypes();
$this->viewTransformers = $config->getViewTransformers();
$this->modelTransformers = $config->getModelTransformers();
$this->dataMapper = $config->getDataMapper();
$this->validators = $config->getValidators();
$this->required = $config->getRequired();
$this->disabled = $config->getDisabled();
$this->errorBubbling = $config->getErrorBubbling();
$this->emptyData = $config->getEmptyData();
$this->attributes = $config->getAttributes();
$this->data = $config->getData();
$this->dataClass = $config->getDataClass();
$this->options = $config->getOptions();
}
示例13: validateChoiceLoaderForDefaultOptions
protected function validateChoiceLoaderForDefaultOptions(FormConfigInterface $config)
{
$this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\Form\\ChoiceList\\DoctrineChoiceLoader', $config->getOption('choice_loader'));
}
示例14: assignFormTypeValues
/**
* @param \Smarty_Internal_Template $template
* @param FormConfigInterface $formFieldConfig
* @param FormView $formFieldView
*/
protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView)
{
$formFieldType = $formFieldConfig->getType()->getInnerType();
/* access to choices */
if ($formFieldType instanceof ChoiceType) {
$template->assign("choices", $formFieldView->vars['choices']);
}
/* access to collections */
if ($formFieldType instanceof CollectionType) {
if (true === $formFieldConfig->getOption('prototype')) {
} else {
/* access to choices */
if (isset($formFieldView->vars['choices'])) {
$template->assign("choices", $formFieldView->vars['choices']);
}
}
}
/* access to thelia type */
if ($formFieldType instanceof TheliaType) {
$template->assign("formType", $formFieldView->vars['type']);
switch ($formFieldView->vars['type']) {
case "choice":
if (!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) {
//throw new
}
$choices = array();
foreach ($formFieldView->vars['options']['choices'] as $value => $choice) {
$choices[] = new ChoiceView($value, $value, $choice);
}
$template->assign("choices", $choices);
break;
}
}
}
示例15: assignFormTypeValues
/**
* @param \Smarty_Internal_Template $template
* @param FormConfigInterface $formFieldConfig
* @param FormView $formFieldView
*/
protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView)
{
$formFieldType = $formFieldConfig->getType()->getInnerType();
/* access to choices */
if ($formFieldType instanceof ChoiceType) {
$template->assign("choices", $formFieldView->vars['choices']);
}
/* access to collections */
if ($formFieldType instanceof CollectionType) {
if (true === $formFieldConfig->getOption('prototype')) {
} else {
/* access to choices */
if (isset($formFieldView->vars['choices'])) {
$template->assign("choices", $formFieldView->vars['choices']);
}
}
}
/* access to date */
if ($formFieldType instanceof DateType || $formFieldType instanceof DateTimeType || $formFieldType instanceof BirthdayType) {
if ('choice' === $formFieldConfig->getOption('widget')) {
/* access to years */
if ($formFieldConfig->getOption('years')) {
$formFieldView->vars['years'] = $formFieldConfig->getOption('years');
$template->assign("years", $formFieldView->vars['years']);
}
/* access to month */
if ($formFieldConfig->getOption('months')) {
$formFieldView->vars['months'] = $formFieldConfig->getOption('months');
$template->assign("months", $formFieldView->vars['months']);
}
/* access to days */
if ($formFieldConfig->getOption('days')) {
$formFieldView->vars['days'] = $formFieldConfig->getOption('days');
$template->assign("days", $formFieldView->vars['days']);
}
/* access to empty_value */
if ($formFieldConfig->getOption('empty_value')) {
$formFieldView->vars['empty_value'] = $formFieldConfig->getOption('empty_value');
$template->assign("empty_value", $formFieldView->vars['empty_value']);
}
}
}
/* access to thelia type */
if ($formFieldType instanceof TheliaType) {
$template->assign("formType", $formFieldView->vars['type']);
switch ($formFieldView->vars['type']) {
case "choice":
if (!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) {
//throw new
}
$choices = array();
foreach ($formFieldView->vars['options']['choices'] as $value => $choice) {
$choices[] = new ChoiceView($value, $value, $choice);
}
$template->assign("choices", $choices);
break;
}
}
}