Dependent values: Difference between revisions
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
The first field (country) is a OOUI DropdownInputWidget with items taken from the template [[Template:Countries]]. | The first field (country) is a OOUI DropdownInputWidget with items taken from the template [[Template:Countries]]. | ||
The second field is a LookupElement with query | The second field (state) is a LookupElement with query | ||
<pre> | <pre> | ||
[[name::<country>]][[states/name::<value>~]] | [[name::<country>]][[states/name::<value>~]] | ||
</pre> | </pre> | ||
where <code><nowiki><country></nowiki></code> is the name of the first field and <code><nowiki><value></nowiki></code> is the value being inserted in the input.<!-- Note that the field names if nested have to be expressed using a path, for instance -->. The requested printout is <code>states/name</code> that | where <code><nowiki><country></nowiki></code> is the name of the first field and <code><nowiki><value></nowiki></code> is the value being inserted in the input.<!-- Note that the field names if nested have to be expressed using a path, for instance -->. The requested printout is <code>states/name</code> that matches the path <code>properties/states/items/properties/name</code> in the schema [[PagePropertiesSchema:Country]]. (where only relevant property names are concatenated, leaving aside <code>properties</code> and <code>items</code> that belong to the schema structure). The query will search json data related to the schema "Country" with value of the property <code>name</code> equal to the value of the first field, and value of the property <code>states/name</code> equal to the state input value. | ||
The third field (city) uses this query | |||
<pre> | |||
[[name::<country>]][[states/name::<state>]][[states/cities/name::<value>~]] | |||
</pre> | |||
The query as above will search json data related to the schema "Country" with value of the property <code>name</code> equal to the value of the first field, value of the property <code>states/name</code> equal to the second field, and value of the property <code>states/cities/name</code> equal to the city input value. The requested printout in this case is <code>states/cities/name</code>. | |||
'''The query searches within a database of 250 wiki pages with content model json as the following [[Data:Countries/Afghanistan]], containing more than 620,000 entries.''' | |||
Revision as of 10:35, 5 December 2023
The following form uses the schema PagePropertiesSchema:Dependent_values.
The first field (country) is a OOUI DropdownInputWidget with items taken from the template Template:Countries.
The second field (state) is a LookupElement with query
[[name::<country>]][[states/name::<value>~]]
where <country>
is the name of the first field and <value>
is the value being inserted in the input.. The requested printout is states/name
that matches the path properties/states/items/properties/name
in the schema PagePropertiesSchema:Country. (where only relevant property names are concatenated, leaving aside properties
and items
that belong to the schema structure). The query will search json data related to the schema "Country" with value of the property name
equal to the value of the first field, and value of the property states/name
equal to the state input value.
The third field (city) uses this query
[[name::<country>]][[states/name::<state>]][[states/cities/name::<value>~]]
The query as above will search json data related to the schema "Country" with value of the property name
equal to the value of the first field, value of the property states/name
equal to the second field, and value of the property states/cities/name
equal to the city input value. The requested printout in this case is states/cities/name
.
The query searches within a database of 250 wiki pages with content model json as the following Data:Countries/Afghanistan, containing more than 620,000 entries.
{{#pagepropertiesform: Dependent values
|title = Dependent values
|action = create
|edit-page =
|return-page =
|view = inline
|popup-size = medium
|css-class =
|pagename-formula =
|edit-freetext = false
|edit-categories = false
|edit-content-model = false
|default-categories = tasks
|default-content-model = json
|layout-align = top
|popup-help = true
|submit-button-text =
|layout = tabs
|submit-button-text =
|validate-button-text =
}}