Use variable to find field?

Try this:

kirby()->hook('panel.page.update', function($page) {
  $problem_fields = array('text', 'field_one', 'field_two');
    foreach ($problem_fields as $field) {
      if ($page->$field()) {
        $text = strip_tags($page->$field());
        $page->update(array($field => $text));
      }
    }
});
2 Likes