[RSS Feed/News] Value formatter can return int type when requested a float

Status
Not open for further replies.

XenForo

Administrative
  • Thread starter
  • Admin
  • #1
PHP:

Code:
$input = 999.00;
$type = \XF\Mvc\Entity\Entity::FLOAT;

$output = \XF::em()->getValueFormatter()->castValueToType($input, $type, []);

var_dump($input); // float(999)
var_dump($output); // int(999)

This is not big problem, if we're not working with entities:
PHP:

Code:
$item = \XF::em()->create('Something:Item'); // cost_amount - FLOAT, cost_currency - STR
$item->cost_amount = 999.00;
$item->cost_currency = 'RUR';
$item->save();

if ($item->isChanged('cost_amount') ||...

Read more

ادامه مطلب...
 
Status
Not open for further replies.
Back
Top Bottom