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
Name | Type(s) | Description |
---|---|---|
$page | Page | Page to save |
$fields | array 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:
|
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