Git Product home page Git Product logo

Comments (8)

fritzmg avatar fritzmg commented on August 30, 2024

It's already a boolean. Why does it try to save an empty string?

from contao-haste.

rabauss avatar rabauss commented on August 30, 2024

I need to debug that again today - it was to late this night ;-)

from contao-haste.

qzminski avatar qzminski commented on August 30, 2024

@aschempp @Toflar should we type cast the value based on its SQL definition before it is even evaluated and stored in the database? The single checkbox value in Contao can return a lot of stuff:

  • true / false
  • '1' / '0'
  • '1' / ''
  • 1 / 0

Or shall we have an internal mapper that converts the values to boolean for evaluation, and sets the correct type right before updating the database?

from contao-haste.

Toflar avatar Toflar commented on August 30, 2024

Casting the value to a string for an empty check ('' === (string) $value) together with Widget::getEmptyValueByFieldType() should be your friend. See https://github.com/contao/contao/blob/5.x/core-bundle/contao/drivers/DC_Table.php#L3215-L3231.

from contao-haste.

rabauss avatar rabauss commented on August 30, 2024

Thanks @Toflar 🧡 that's what I also figured out while analysis.
I startet a PR. But I need to test it with my project in the next few days!

from contao-haste.

rabauss avatar rabauss commented on August 30, 2024

Unfortunately the getEmptyValueByFieldType is not enough or better say in my case it is already false because of the callback but the database update

$this->connection->update($dc->table, [$settings['field'] => $value], ['id' => $id]);

rejects false with Incorrect integer value: '' for column.

Do we need some special cast for doctrine call?

from contao-haste.

Toflar avatar Toflar commented on August 30, 2024

Why is your value an empty string if it expects a boolean?

from contao-haste.

fritzmg avatar fritzmg commented on August 30, 2024

Do we need some special cast for doctrine call?

You need to specify the field type otherwise Doctrine will cast everything to string (which is then an empty string for false).

from contao-haste.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.