Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] Feeding float values to a choice form type #13817

Copy link
Copy link
Closed
@kminh

Description

@kminh
Issue body actions

I'm trying to setup something like this with Symfony 2.6.1:

$builder
    ->add('field', 'choice', [
        'choices' => array_combine(range(0.1, 1.0, 0.1), range(0.1, 1.0, 0.1))
    ]);

and this is the mapping for Doctrine:

    field:
        type: decimal
        precision: 2
        scale: 1
        options:
            default: 1.0

The field never shows the value 1.0 as selected when it is (works fine for 0.1 => 0.9). I have tried converting all float values to string using number_format but doesn't work either.

I have also tried using http://symfony.com/doc/current/reference/forms/types/choice.html#choice-list, but taking the example on that page I get this:

<select>
   <option value="0">Full</option>
   <option value="1">Half</option>
</select>

as you can see, there's no float values here (shouldn't it be 1 => Full, 0.5 => Half?) Is this a bug with ChoiceList or the example is incorrect?

Thanks in advanced for any insight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.