Skip to content

Instantly share code, notes, and snippets.

@benjaminrau
Last active April 20, 2017 11:06
Show Gist options
  • Save benjaminrau/3b27a6bc6cdd112afac2 to your computer and use it in GitHub Desktop.
Save benjaminrau/3b27a6bc6cdd112afac2 to your computer and use it in GitHub Desktop.
How to have a tca field of type float/double but nullable
<?php
class Double2With4DecimalsFormat {
function returnFieldJS() {
return '
return value.replace(",", ".");
';
}
function evaluateFieldValue($value, $is_in, &$set) {
if ('' == $value) {
return NULL;
}
return sprintf('%01.4f', $value);
}
}
<?php
$TYPO3_CONF_VARS['SC_OPTIONS']['tce']['formevals']['Double2With4DecimalsFormat'] = 'EXT:nmidbproducts/Classes/Formevals/Double2With4DecimalsFormat.php';
index_value double(11,4) DEFAULT NULL,
<?php
'index_value' => array(
'exclude' => 1,
'label' => 'LLL:EXT:nmidbproducts/Resources/Private/Language/locallang_db.xlf:tx_nmidbproducts_domain_model_fructose.index_value',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'Double2With4DecimalsFormat'
)
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment