You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In master branch of Jelly we had form items generating. In this functional there was a data formatting mechanism (such as pretty_format for timestamps) that helped to convert data that was requested from the database in database (or some other) format to a readable to the user format.
In 3.1 unstable branch we offer to make a 'format' method that will be in model and tries to format a field data to represent it in some pretty format that was set in the model meta ('pretty_format' in field properties).
It would be defined in model meta initialization like something this:
'birthday' => Jelly::field('Timestamp', array(
'pretty_format' => 'd.m.Y',
)),
/* for Integer fields would be used number_format function and params
* for pretty_format should set as
* array(int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
*/
'price' => Jelly::field('Float', array(
'pretty_format' => array(2, ',', ' ')),
)),
'monkeys' => Jelly::field('String', array(
'pretty_format' => '[%010s]\n', // sprintf format is set
)),
And will be called like that:
// fields formats
echo $model->format('birthday'); // will echo formatted date: 04.02.1999
echo $model->format('price'); // will echo formatted price: 12 000,25
echo $model->format('monkeys'); // will echo formatted string: [0000monkey]
The text was updated successfully, but these errors were encountered:
In master branch of Jelly we had form items generating. In this functional there was a data formatting mechanism (such as pretty_format for timestamps) that helped to convert data that was requested from the database in database (or some other) format to a readable to the user format.
In 3.1 unstable branch we offer to make a 'format' method that will be in model and tries to format a field data to represent it in some pretty format that was set in the model meta ('pretty_format' in field properties).
It would be defined in model meta initialization like something this:
And will be called like that:
The text was updated successfully, but these errors were encountered: