I don't like the else here. Instead you could do:

```php
$scaffoldFields = array_keys($model->schema());
if (in_array($request->action, array('index','view'))) {
  $scaffoldFields = array_merge($scaffoldFields, array_keys($model->virtualFields));
}
```