Page 1 of 1
How to format a numeric custom field?
Posted: 21 Mar 2021, 12:33
by pollevr
Hi all,
I created a numeric float custom field like this:

- custom_field_config.png (19.19 KiB) Viewed 1804 times
My custom field was displayed like this:

- custom_field_orig.png (2.68 KiB) Viewed 1804 times
but I would print this custom filed on a custom format like this:

- custom_field_formatted.png (3.07 KiB) Viewed 1804 times
How can I do it?
Thanks.
Re: How to format a numeric custom field?
Posted: 21 Mar 2021, 13:39
by pollevr
I found a solution, in bug_view_inv.php:
Code: Select all
# Custom Fields
if( isset( $t_issue['custom_fields'] ) ) {
foreach( $t_issue['custom_fields'] as $t_custom_field ) {
$t_def = custom_field_get_definition( $t_custom_field['field']['id'] );
echo '<tr>';
echo '<th class="bug-custom-field category" colspan="2">', string_display_line( lang_get_defaulted( $t_def['name'] ) ), '</th>';
echo '<td class="bug-custom-field" colspan="4">';
//print_custom_field_value( $t_def, $t_custom_field['field']['id'], $f_issue_id );
if($t_def['type']==2 && is_numeric ($t_custom_field['value'])){
echo number_format($t_custom_field['value'], 2, ",", ".");
}else{
print_custom_field_value( $t_def, $t_custom_field['field']['id'], $f_issue_id );
}
echo '</td></tr>';
}
Let me know if there is a better solution.
Thank you.