metamodels / attribute_decimal Goto Github PK
View Code? Open in Web Editor NEWThe decimal attribute (floating point)
License: GNU Lesser General Public License v3.0
The decimal attribute (floating point)
License: GNU Lesser General Public License v3.0
I confirm that:
(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 |
When the attribute value is an empty string (''), it will be saved as "0" in the database. Expected behavior would be saving null
.
/** @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
.
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é
when declared as mandatory in the input-mask the Asterisk is missing.
On submission you will get no error-message - instead it fills in a "0" silently.
Ein Komma (,) wird grundsätzlich in einen Punkt umgewandelt. Das Komma muss aber für Beträge erhalten bleiben, damit man zum Bsp. Euro Beträge darstellen kann.
Ü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.
Möchte ich einen Betrag von 19,90 darstellen
Das Attribut "decimal" kürzt die "Null" ohne Hinweis einfach weg. Für Eurobeträge sind Nachkommastellen aber notwendig!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.