Use update() with kirby page builder

Hello,

Is it possible to use the $page–>update() in combination with the kirby page builder?

try {

  page('mypage')->update(array(
'title'        => 'A new title',
'text'         => 'Some text',
'anotherfield' => 'Some more data'
  ));

  echo 'The page has been updated';

} catch(Exception $e) {

  echo $e->getMessage();

}

So I want to update the ogTitle field of the builder below:

labs:
    label: Labs
    type: builder
    fieldsets:
      article:
        label: Article
        entry: >
            {{url}}
        fields:
          url:
            label: Url
            type: url
          ogTitle:
            label: Title
            type: text
          noImage:
            label: Don't show OG Image
            type: checkbox
            width: 1/2
          size:
            label: Size
            type: select
            width: 1/2
            options:
              ls: Large Square
              ss: Small Square
              ll: Large Landscape
              sp: Small Portrait
      gif:
        label: GIF
        fields:
          gifImg:
            label: GIF
            type: image
          gifUrl:
            label: GIF URL
            type: url

Best wishes,

Do you want to update all instances of the title field with the same value?

@texnixe Yes all instances get the same value :slight_smile:

<?php

$field = $page->text()->yaml();
$filteredArray = array_filter($field, function($ar) {
   return ($ar['_fieldset'] == 'article');
});
$function = function($n){
    return array_replace($n, array('title' => 'abc'));
};
$newArray = array_map($function, $filteredArray);
$newdata = array_replace($field, $newArray);
$data = yaml::encode($newdata);
// then update field with $data
try {

  page('mypage')->update(array(
    'labs'        => $data

  ));

  echo 'The page has been updated';

} catch(Exception $e) {

  echo $e->getMessage();

}
?>