Git Product home page Git Product logo

attribute_decimal's People

Contributors

andreasisaak avatar baumannsven avatar cliffparnitzky avatar discordier avatar dmolineus avatar kikmedia avatar minimodel avatar richardhj avatar stefanheimes avatar zonky2 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

attribute_decimal's Issues

Empty string will be saved as "0" in database

Checklist before I submit this issue report

I confirm that:

My environment is:

(Please fill in the actual values from your environment)

Key Value Comments
PHP version: 7.0
Contao version: 3.5.21
MetaModels version: hotfix15
Installation via composer yes
Installed MetaModels packages all

Issue description

When the attribute value is an empty string (''), it will be saved as "0" in the database. Expected behavior would be saving null.

Steps to reproduce

/** @var \MetaModels\IItem $item */
$item->set('decimal-attr', '');
$item->save();

This could be added to the attribute class.

    public function setDataFor($arrValues)
    {
        // Translate all '' values to null, so they will not set as `0` in the database.
        $arrValues = array_map(function ($value) {
            return '' === $value ? null : $value;
        }, $arrValues);

        parent::setDataFor($arrValues);
    }

I'm not sure, whether this is a issue, because this does not happen when using the dcg (in the back end).
When this issue will be confirmed, I could provide a PR.

Same for attribute_numeric.

xhtml Template fehlt

Hallo,

bei den Templates ist kein xhtml-Template vorhanden.
Vielleicht könnte das noch zugefügt werden. Es reicht wohl aus, ein html5-Template zu kopieren und in .xhtml umzubenennen.

VG und danke
André

Zahlenformatierung im BE

Über den Attribut-Typ Decimal erfasse ich Preise. Mit Preisen wie 1.22 oder 100.99 funktioniert das bestens, jedoch bei Preisen wie 1.20 oder 100.90 wird die letzte 0 einfach nicht gespeichert. Ändere ich in der DB die Tabellen-Eigenschaft bei der entsprechenden Tabelle von „double NULL“ in „double(12,2) NULL“, wird auch die letzte 0 korrekt gespeichert.

Es wäre begrüßenswert, wenn man dem attribute_decimal ein Price-Tag mitgeben könnte, um im BE Preisformatierung mit Komma, Tausenderpunkt und abschließende Null zu realisieren. Redakteure können dann im BE Preise wie 1.234,00 erfassen und sich anzeigen lassen.

Im FE formatiere ich den Preis im entsprechenden Template mittels number_format.

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.