将class html属性设置为多维数组中的特定变量

I have a question that is probably extremely simple, but I just can't get my head around it. And if I'm using the wrong lingo, please let me know....

I'm using a list_helper class to help display a list of records, 1 set per row.

Here is the code I'm working with:

foreach ($records as $record) {
  $record_array = get_object_vars($record);
  $row = array();

  foreach ($fields as $i => $field) {
    $value = NULL;

    if (isset($field['getter']) && is_callable($field['getter'])) {
      $value = call_user_func($field['getter'], $record);
    } else if (isset($field['key']) && isset($record_array[($key = $field['key'])])) {
      $value = $record_array[$key];
    }

    if(isset($field['class_attr'])) { 
      echo $value;
      $value->attributes['class'] = 'test';
    }
  }
}

What I'm trying to achieve (in the last 4 lines of code) is set an HTML class attribute to a specific record. One of the fields (completion_date) has been tagged as having a 'class_attr' value assigned to it in another php page. Something like:

'label' => 'compl_date',
'class_attr' => 'test'

When I echo $value it returns the correct field, but when I want to assign a HTML class attribute to that date field (i.e. completion_date), it returns an

error: Warning: Attempt to modify property of non-object.

This is not code I have written myself, so I'm sure I'm missing something here.

When looking at the $field object, it returns the following details:

Array
(
[0] => Array
    (
        [label] => Completion date
        [class_attr] => testcase
        [getter] => Closure Object
            (
                [this] =>
    local_courses_all_current_courses_list Object
                    (

[model:local_courses_all_current_courses_list:private] =>
local_courses_current_courses_model Object
                            (
                            )

                        [params:local_base_list_helper:private] => Array
                            (
                                [action] => 0
                                [action_arg] => 
                                [action_confirm] => 
                                [page] => 0
                                [per_page] => 30
                            )

                        [prefix:local_base_list_helper:private] => 
                        [display] => local_base_display_helper Object
                            (
                            )

                    )

                [parameter] => Array
                    (
                        [$record] => 
                    )

            )

    )

)

Can anyone point me in the right direction? I have been wrestling with this little thing for over 2 days now and I'm out of options....

Thanks