You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -315,11 +315,12 @@ class blocks_used_config extends simple_metric_config {
315
315
That's it.
316
316
There is no need to override any of the `metric_config` methods by hand.
317
317
318
-
> [!IMPORTANT]
319
-
> The [constructor property promotion][php docs constructor promotion] is _required_ here! Same as making the config parameters **public**.
320
-
321
318
This data class is meant to represent both the JSON "schema" for (de-)serializing the actual metric config from/to the database and the shape of the initial/submitted form data.
322
319
320
+
> [!IMPORTANT]
321
+
> Using [constructor property promotion][php docs constructor promotion] and declaring those properties `public` is done very deliberately!
322
+
> The class allows ways to achieve the same results with a different setup, but this is the most concise way.
323
+
323
324
Under the hood, the `simple_metric_config` class will also automatically define the config form fields appropriately.
324
325
This means it will do the following for each public property in the constructor:
325
326
@@ -330,7 +331,7 @@ This means it will do the following for each public property in the constructor:
330
331
5. Add a validation rule for that input (optionally).
331
332
332
333
So our example config form will have a text input field named `minblockagehours` and a checkbox for `includehidden`.
333
-
Also, the type for the former will be `PARAM_FLOAT` and its value will be immediately validated to be numeric on the client side.
334
+
The type for the former will be set to`PARAM_FLOAT` and its value will be immediately validated to be numeric on the client side.
334
335
335
336
> [!NOTE]
336
337
> The order of the constructor parameters determines the order of the form fields.
0 commit comments