Skip to content

Error when submitting empty value for optional choice field in Propel #16478

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

Closed
mcrawford-dayspring opened this issue Nov 5, 2015 · 4 comments

Comments

@mcrawford-dayspring
Copy link

Issue #14583 was fixed for Doctrine, but is still broken for Propel and the Propel Bridge (PostgreSQL for the database). Submitting an empty value for a choice list gives the error:

Invalid text representation: 7 ERROR: invalid input syntax for integer: ""

The code from the original post in #14583 (adjusted for PHP 5.3) seems to fix the problem:

public function getChoicesForValues(array $values)
    {
        if (empty($values)) {
            return array();
        } else {
            $first = reset($values);
            if (empty($first)) {
                return array();
            }
        }
@jakzal jakzal added the Form label Nov 6, 2015
@jakzal
Copy link
Contributor

jakzal commented Nov 6, 2015

@mcrawford-dayspring what's actually being submitted in your case?

@mcrawford-dayspring
Copy link
Author

Just an empty string is being submitted:

string(0) ""

My field is defined as a ModelType with an empty_value property, and is not required by validation:

->add('eventData', 'model', array(
        'class'       => 'zzzBundle\Model\EventData',
        'property'    => 'eventDateAndName',
        'empty_value' => '- NO EVENT SELECTED -',
        'query'       => EventDataQuery::create()
                    ->filterByEventDate(new DateTime(), Criteria::GREATER_THAN)
                    ->orderByEventDate(Criteria::DESC)
    ,
        'required'    => false,
))

@stood
Copy link

stood commented Nov 26, 2015

👍
In ModelChoiceList for method getChoicesForValues values is not empty but the first value of array is empty.

@xabbuh
Copy link
Member

xabbuh commented Jun 21, 2017

closing here as the PropelBridge is no longer part of the Symfony core since 2.7

@xabbuh xabbuh closed this as completed Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants