From 9dbd7dd079189c66268b9f134a49b4324c490d88 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 11 Oct 2024 16:15:27 -0400 Subject: [PATCH] =?UTF-8?q?Add=20$page->saveFields([=20'field1,=20'field2'?= =?UTF-8?q?,=20'etc.'=20])=20method=20as=20a=20front-end=20to=20the=20adde?= =?UTF-8?q?d=20$pages->saveFields($page,=20[=20=E2=80=A6=20])=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wire/core/Page.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wire/core/Page.php b/wire/core/Page.php index 2961fda4..49175f40 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -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. * @return bool Returns true on success false on fail * @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()) { @@ -2376,6 +2376,21 @@ class Page extends WireData implements \Countable, WireMatchable { 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