Skip to content

add missing choices_as_values options #7949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extend
'Standard Shipping' => 'standard',
'Expedited Shipping' => 'expedited',
'Priority Shipping' => 'priority',
)
),
'choices_as_values' => true,
));
}

Expand Down Expand Up @@ -395,6 +396,7 @@ method to ``ShippingType``, which receives the shipping configuration::
{
$resolver->setDefaults(array(
'choices' => array_flip($this->shippingOptions),
'choices_as_values' => true,
));
}

Expand Down
10 changes: 6 additions & 4 deletions form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,10 @@ sport like this::
$positions = null === $sport ? array() : $sport->getAvailablePositions();

$form->add('position', 'entity', array(
'class' => 'AppBundle:Position',
'class' => 'AppBundle:Position',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to your PR but what about dropping this doctrine notation in favor of class constants in the docs? The only advantage it has today IMO is eventually for config files with factory methods (even there I always prefer fqcn though).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. In #7907 we did that when using the getRepository() method. I will prepare another PR for other places where we use this (like here).

'placeholder' => '',
'choices' => $positions,
'choices' => $positions,
'choices_as_values' => true,
));
}
);
Expand Down Expand Up @@ -553,9 +554,10 @@ The type would now look like::
$positions = null === $sport ? array() : $sport->getAvailablePositions();

$form->add('position', 'entity', array(
'class' => 'AppBundle:Position',
'class' => 'AppBundle:Position',
'placeholder' => '',
'choices' => $positions,
'choices' => $positions,
'choices_as_values' => true,
));
};

Expand Down