File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ class SearchEditor extends Form
6363 * Set the filter query string to populate the form with
6464 *
6565 * Use {@see SearchEditor::getParser()} to subscribe to parser events.
66+ * Calling this resets any filter previously set by {@see SearchEditor::setFilter()}
6667 *
6768 * @param string $query
6869 *
@@ -71,6 +72,7 @@ class SearchEditor extends Form
7172 public function setQueryString ($ query )
7273 {
7374 $ this ->queryString = $ query ;
75+ $ this ->filter = null ;
7476
7577 return $ this ;
7678 }
@@ -149,6 +151,25 @@ public function getFilter()
149151 return $ this ->filter ;
150152 }
151153
154+ /**
155+ * Set the filter to populate the form with
156+ *
157+ * Overwrites any query string previously set by {@see SearchEditor::setQueryString()}.
158+ *
159+ * @param Filter\Rule $filter
160+ *
161+ * @return $this
162+ */
163+ public function setFilter (Filter \Rule $ filter ): static
164+ {
165+ $ this ->filter = $ filter ;
166+ $ this ->queryString = $ filter instanceof Filter \Chain && $ filter ->isEmpty ()
167+ ? ''
168+ : (new Renderer ($ filter ))->setStrict ()->render ();
169+
170+ return $ this ;
171+ }
172+
152173 /**
153174 * Get inline stylesheet
154175 *
You can’t perform that action at this time.
0 commit comments