1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 07:47:00 +02:00

Add $page->saveFields([ 'field1, 'field2', 'etc.' ]) method as a front-end to the added $pages->saveFields($page, [ … ]) method

This commit is contained in:
Ryan Cramer
2024-10-11 16:15:27 -04:00
parent 0ef8a4de0b
commit 9dbd7dd079

View File

@@ -2350,7 +2350,7 @@ class Page extends WireData implements \Countable, WireMatchable {
* @param array $options See Pages::save() documentation for options. You may also specify $options as the first argument if no $field is needed. * @param array $options See Pages::save() documentation for options. You may also specify $options as the first argument if no $field is needed.
* @return bool Returns true on success false on fail * @return bool Returns true on success false on fail
* @throws WireException on database error * @throws WireException on database error
* @see Pages::save(), Pages::saveField(), Pages::saveReady(), Pages::saveFieldReady(), Pages::saved(), Pages::fieldSaved() * @see Pages::save(), Page::saveFields(), Pages::saveField(), Pages::saveReady(), Pages::saveFieldReady(), Pages::saved(), Pages::fieldSaved()
* *
*/ */
public function save($field = null, array $options = array()) { public function save($field = null, array $options = array()) {
@@ -2376,6 +2376,21 @@ class Page extends WireData implements \Countable, WireMatchable {
return $pages->save($this, $options); return $pages->save($this, $options);
} }
/**
* Save only the given named fields for this page
*
* @param array|string $fields Array of field name(s) or string (CSV or space separated)
* @param array $options See Pages::save() documentation for options.
* @return array Names of fields that were saved
* @throws WireException on database error
* @see Page::save()
* @since 3.0.242
*
*/
public function saveFields($fields, array $options = array()) {
return $this->wire()->pages->saveFields($this, $fields, $options);
}
/** /**
* Quickly set field value(s) and save to database * Quickly set field value(s) and save to database