Skip to content

Commit 7900e10

Browse files
committed
New: new Options() can now be passed parameters for easy creation of options without needing the chained methods, for the most simple of use cases.
1 parent 1b7922b commit 7900e10

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Editor/Options.php

+25-3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,28 @@ class Options extends Ext
107107
/** @var string Column name containing the value */
108108
private $_value;
109109

110+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
111+
* Constructor
112+
*/
113+
114+
/**
115+
* Constructor.
116+
*
117+
* @param string $table As a string this is the database table name - see `->table()`. If given as a function, then it is passed to `->fn()` as a custom function.
118+
* @param string $value The database column name to use as the value for the options - see `->value()`
119+
* @param string $label The database column name to use as the label for the options - see `->label()`.
120+
*/
121+
public function __construct($table = null, $value = null, $label = null)
122+
{
123+
if (is_string($table)) {
124+
$this->table($table);
125+
$this->value($value);
126+
$this->label($label);
127+
} elseif (is_callable($table)) {
128+
$this->fn($table);
129+
}
130+
}
131+
110132
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
111133
* Public methods
112134
*/
@@ -272,10 +294,10 @@ public function render($_ = null)
272294
}
273295

274296
/**
275-
* Get / set the flag to indicate if the options should always be refreshed
276-
* (i.e. on get, create and edit) or only on the initial data load (false).
297+
* Get / set the search only flag. If enabled the options will only be resolved when doing a
298+
* search for options on this specific instance.
277299
*
278-
* @param bool|null $_ Flag to set the always refresh set to, or null to
300+
* @param bool|null $_ Flag to set the search only set to, or null to
279301
* get the current state.
280302
*
281303
* @return ($_ is null ? boolean : $this)

0 commit comments

Comments
 (0)