$page->update()
Updates the page data
$page->update(array $input = null, string $languageCode = null, bool $validate = false): Kirby\Cms\PageParameters
| Name | Type | Default | 
|---|---|---|
| $input | array | null | 
| $languageCode | string | null | 
| $validate | bool | false | 
Return type
This method does not modify the existing $page object but returns a new object with the changes applied. Learn more →
Parent class
Example
Kirby's objects are immutable. That means, when you modify an object like $page, $file etc. using a method like update(), changeTitle() and so on, a new  object is returned. Therefore, you have to store the returned object in a new variable to be able to further work with it.
try {
  $newPage = page('mypage')->update([
    'title'        => 'A new title',
    'text'         => 'Some text',
    'anotherfield' => 'Some more data'
  ]);
  echo 'The page has been updated:';
} catch(Exception $e) {
  echo $e->getMessage();
}Updating a field by callback
$newPage = $page->update([
  'title' => function($title) {
    return Str::lower($title);
  }
]);Multi-language site
Use the optional $lang parameter to specify the language you want to update.
try {
  $newPage = page('mypage')->update([
    'title'        => 'A new title',
    'text'         => 'Some text',
    'anotherfield' => 'Some more data'
  ], 'en');
  echo 'The page has been updated';
} catch(Exception $e) {
  echo $e->getMessage();
}