Jonathan Lahijani Posted July 26, 2021 Share Posted July 26, 2021 I have a decimal field that has been set to non-editable. I want to format the value so it's nicer when editing a page. For example, instead of showing 123456, I want to format it to show $123,456.00 What is the proper way to hook into it and modify the rendered value? Link to comment Share on other sites More sharing options...
Robin S Posted July 28, 2021 Share Posted July 28, 2021 FieldtypeDecimal uses InputfieldFloat as its inputfield, and it's the renderValue() method that determines what is shown when a field is not editable. So you could do this: $wire->addHookAfter('InputfieldFloat::renderValue', function(HookEvent $event) { /** @var InputfieldFloat $inputfield */ $inputfield = $event->object; $field = $inputfield->hasField; if($field && $field->name === 'your_field_name') { $event->return = '$' . number_format((float) $inputfield->value, 2); } }); 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now