Preset queries
Goerp have an option to define Preset queries, which will be saved into the template data and executed every time when page loaded without passing any form data. Usually preset option is used while querying the table of records. However, inputs also may have preset option in very specific cases. Check data source definitions in editor to ensure if model supports presets or not.
To use presets, just add input tags somewhere in the template, but outside any form, and set desired values:
<body>
<input type="hidden" name="Preset.Api.ModelQuery.FieldOne" value="1">
<input type="hidden" name="Preset.Api.ModelQuery.FieldTwo" value="two">
<!-- When template loaded from the store, goerp already knows the filter criteria based on presets -->
<!-- and this list will contain records that are corresponds to preset query inputs -->
<ul>
{{ range .Data.Api.ModelList }}
<li>{{ .Name }}</li>
{{ end }}
</ul>
</body>
Define all Preset inputs outside the form, so they will not mess up with form data (In most cases goerp editor will throw an error during saving). That make sense, because they are not related to the form at all, consider them as āimportsā in javascript, so write them somewhere in the beginning of the document (page or partial, in case of partial inside ācontent-blockā)