PagesEditor::editor method

Save multiple named fields from given page

Available since version 3.0.242.

Example

// you can specify field names as array…
$a = $pages->saveFields($page, [ 'title', 'body', 'summary' ]);

// …or a CSV string of field names:
$a = $pages->saveFields($page, 'title, body, summary');

// return value is array of saved field/property names
print_r($a); // outputs: array( 'title', 'body', 'summary' )

Usage

// basic usage
$array = $pages->editor->saveFields(Page $page, $fields);

// usage with all arguments
$array = $pages->editor->saveFields(Page $page, $fields, array $options = []);

Arguments

NameType(s)Description
$pagePage

Page to save

$fieldsarray string string[] Field[]

Array of field names to save or CSV/space separated field names to save. These should only be Field names and not native page property names.

$options (optional)array

Optionally specify one or more of the following to modify default behavior:

  • quiet (bool): Specify true to bypass updating of modified user and time Default:false
  • noHooks (bool): Prevent before/after save hooks, please also use $pages->___saveFields() for call. Default:false
  • See $options argument in Pages::save() for additional options.

Return value

array

Array of saved field names (may also include property names if they were modified)

Exceptions

Method can throw exceptions on error:

  • WireException


$pages->editor methods and properties

API reference based on ProcessWire core version 3.0.252