This topic is locked

How to change field labels via php before page display

9/2/2016 4:30:08 PM
PHPRunner Tips and Tricks
F
FunkDaddy author

Say you want to change a field label on list page, side search panel, add, edit, view, etc (any page).
Add this to your After Application Initialized event:


function setFieldLabel($table, $field, $custom_label )

{

global $field_labels;

if(!array_key_exists($table,$field_labels))

return "";

@$field_labels[$table][mlang_getcurrentlang()][$field] = $custom_label;

}


Now in whichever page you need to update label simply add to before display event:


setFieldLabel('db_table_name', 'db_field_name', 'My Cool New Label');


I had to come up with this because the $xt->assign('fieldname', 'new_value'); example in manuals simply do not work for $label vars shown inside out html templates (when viewing them in visual editor in html mode).
Hope this helps folks
Marcelo Ramagem

emendoza 2/11/2017

Friend FunkDaddy, excellent tips!

I've had this need to change a field label.
My congratulations for this contribution!