DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:struct:bureaucracy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:struct:bureaucracy [2016-03-31 15:56] andiplugin:struct:bureaucracy [2022-11-04 07:38] (current) – [Prefilling] Add image, Clarification on the format of the data saggi
Line 1: Line 1:
 +<= [[plugin:struct|Struct Plugin]]
 +
 ====== Struct Plugin: Bureaucracy Support ====== ====== Struct Plugin: Bureaucracy Support ======
  
-The struct plugin supports integration with the [[plugin:bureaucracy|Bureaucracy Plugin]]. This allows reusing the input mechanisms of the different [[plugin:struct:type|types]] in bureaucracy forms and creation of structured data when pages are created through Bureaucracy's template action.+The Struct Plugin supports integration with the [[plugin:bureaucracy|Bureaucracy Plugin]]. This allows reusing the input mechanisms of the different [[plugin:struct:type|types]] in bureaucracy forms and creation of structured data when pages are created through Bureaucracy's template action or saving them into lookup schemas.
  
 ===== Single Field ===== ===== Single Field =====
  
-You can use any field from any defined schema as a field in a bureaucracy form. To do so simply use the type ''struct_field'' and specify the field name in the form of ''//<schema>//.//<name>//''.+You can use any field from any defined schema as a field in a Bureaucracy form. To do so simply use the type ''struct_field'' and specify the field name in the form of ''//<schema>.<name>//''.
  
 <code> <code>
Line 17: Line 19:
 The defined (translated) label will automatically be used for the field as well as all the validation rules configured in the schema. The defined (translated) label will automatically be used for the field as well as all the validation rules configured in the schema.
  
-You can use the the value entered in a struct field as any other value for templating. Eg. you can use ''@@products.product@@'' to access the value of the example above.+You can use the value entered in a Struct field as any other value for templating. Eg. you can use ''@@products.product@@'' to access the value of the example above.
  
-All struct values will be assigned to the resulting pages of (when using the bureaucracy template action), provided the schema assignments match.+All Struct values will be assigned to the resulting pages of (when using the Bureaucracy template action), provided the schema assignments match.
  
 ===== Complete Schema ===== ===== Complete Schema =====
  
-Instead of adding individual fields to a bureaucracy form as described above, you can also add a whole schema to the form. To do so, simply use the ''struct_schema'' command.+Instead of adding individual fields to a Bureaucracy form as described above, you can also add a whole schema to the form. To do so, simply use the ''struct_schema'' command.
  
 <code> <code>
Line 29: Line 31:
 Action template templates:product product : Action template templates:product product :
 textbox name @ textbox name @
-struct_schema "product" !+struct_schema "products" !
 submit "Create new product" submit "Create new product"
 </form> </form>
Line 35: Line 37:
  
 Please note that all additional parameters given will be added to each individual field. Eg. you can only make all fields of the schema mandatory or optional. Please note that all additional parameters given will be added to each individual field. Eg. you can only make all fields of the schema mandatory or optional.
 +
 +In this way you can't use ''@'' [[plugin:bureaucracy#defining_the_destination_s|to mark fields to be used as page names]]. To use a field of the struct_schema as page name you can define it with the bureaucracy syntax ''@@'' and the fully qualified name of the struct field e.g. ''products.product'' in the [destination]. The [separator] '':'' is not needen then.
 +
 +<code>
 +<form>
 +Action template templates:product destination:@@products.product@@
 +textbox name @
 +struct_schema "products" !
 +submit "Create new product"
 +</form>
 +</code>
 +
 +
 +===== Action struct_lookup =====
 +
 +You can save data from bureaucracy forms into lookup schema, using ''struct_lookup'' form action. To do so add ''action struct_lookup'' and  desired lookup fields using ''struct_field'' or ''struct_schema''. Eg. 
 +
 +<code>
 +<form>
 +action struct_lookup
 +struct_field "someschema.name"
 +submit "Save into lookup"
 +</form>
 +</code>
 +
 +==== Prefilling ====
 +
 +You can prefill fields by adding a ''='' after the field name. You must pre-fill with the formats stored in the database, not the formats you get when the table or page is displayed (e.g. dates are in Y-m-d format, independent of your locale). \\
 +When you set a ''Text'' use ''%%"=some text"%%'', for a date use ''=2020-01-01'' or simple variables like ''=%Y-%m-%d''. \\
 +For Lookup-Fields on Page-Schemes you must setup the complete namespace to the target (e.g. ''%%"=[""ns:ns1:ns2:page"",0]"%%''). For Lookup-Fields in in Lookup-Schemes you must set the ''rid'' (e.g. ''%%"=["""",1]"%%'') of the row. Watch out for the double-quotes! This form is valid for struct-db starting from version 16.
 +
 +Following code
 +
 +<code>
 +<form>
 +action struct_lookup
 +struct_field "employeetraining.employee"
 +struct_field "employeetraining.training" "=[""ns:ns1:ns2:page"",0]"
 +struct_field "employeetraining.date" =%Y-%m-%d
 +struct_fieldhidden "employeetraining.last date" =%Y-%m-%d
 +submit "Save into lookup"
 +</form>
 +</code>
 +
 +will result in this (localized in Schema-Editor):
 +
 +{{https://i.ibb.co/B2Q6Y59/sampleform-struct-lookup.png|struct-lookup}}
 +
plugin/struct/bureaucracy.1459432576.txt.gz · Last modified: 2016-03-31 15:56 by andi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki