I'm trying to change the value of a field in a view programatically but i find some problems.
first is that even though I created a Global: custom text field which field id is 'nothing', It's value remain unchanged and the value is applied to a new field created at the end of the view.
Second is that this function creates some errors and drupal send lots of notices:
Notice: Undefined property: stdClass::$wrapper_prefix in include() (line 32 of /my/path/sites/all/modules/views/theme/views-view-fields.tpl.php).
Notice: Undefined property: stdClass::$label_html in include() (line 33 of /my/path/sites/all/modules/views/theme/views-view-fields.tpl.php).
Notice: Undefined property: stdClass::$wrapper_suffix in include() (line 35 of /my/path/sites/all/modules/views/theme/views-view-fields.tpl.php).
My code is:
function real_estast_sub_preprocess_views_view_fields(&$vars) {
$view = $vars['view'];
foreach ($view->field as $id => $field) {
// change the global custom text content depend on result (node id)
if ($vars['row']->nid == 1625){
$vars['fields']['nothing']->content = '666€';
}else{
$vars['fields']['nothing']->content = $vars['row']->field_data_field_price_field_price_value."€/noche ";
}
}
}
What's the problem here? I tried to follow all the steps explained in:
How to insert values into Global custom text field of views programmatically?
Edit: I soolved the notices form drupal by adding:
$vars['fields']['nothing']->wrapper_prefix = ''; $vars['fields']['nothing']->wrapper_suffix = ''; $vars['fields']['nothing']->label_html = '';
But it's like I'm defining a totally new field instead of assigning a value to the existing one