Changes

From Gramps

Addon:Forms Gramplet

7,005 bytes removed, 02:10, 5 October 2025
no edit summary
To see a full list of the supported {{man label|Code}}'s for definitions included with the addon that are available, See: [[Addon:Form Definitions]]
=== Writing your own form definitions ===<!-- split to separate page as typical users will not need to know any of this --> {{man note|Note: For the To create a form to work|Make sure that your definition file is saved using UTF-8 encoding.}}see If a form you require is not in the list of supported * [[Addon:Form Definitions|Form DefinitionsCreation|definitions]] then you can write your own. Form definitions are stored in XML files. These are located in the Form directory beneath your [[Gramps_{{Version manual}}_Wiki_Manual_-_User_Directory|user plugins directoryCreation]]. The file called <code>form_xx.xml</code>(where ''xx'' is a country code), is provided in the download, and contains some common definitions. Additional files called <code>custom.xml</code> and <code>test.xml</code> will also be searched. Definition files consist of an XML declaration followed by a <code>forms</code> element.  <?xml version="1.0" encoding="UTF-8" ?> <forms> </forms> The <code>forms</code> element contains a number of <code>form</code> elements, each representing a form definition. The form start-tag contains 4 attributes: * <code>id</code> : A unique code to identify the form definition. You will use this code in the "Form" attribute of the source.* <code>type</code>: The type of the event created by the form editor. This value will appear in the "<code>Type</code>" column of events ("EventType"). It would be wise to avoid standard ones, for example, to add death information you could specify "Death.Info" or another one you make up (Data loss is possible otherwise).* <code>title</code> : A description of the form. It should be possible to use anything here.* <code>date</code> : An optional date in a Gramps date format. This is only useful for census definitions or similar events that happen on a specific date.  <form id='UK1841' type='Census' title='1841 UK Census' date='6 Jun 1841'> The form is divided into sections which describe the information that needs to be captured for people performing a given role in the event. Each form element should contain at least one section element. The <code>section</code> start-tag can specify these 3 attributes: * <code>role</code> : The role that people in this section perform in the event. This value will appear in the "<code>Role</code>" column of events ("EventRoleType").* <code>type</code> : The type of section. This defines how a section is displayed and people are selected. Allowed values are: '<code>person</code>' for a single person, '<code>multi</code>' for one or more people, or '<code>family</code>' for two people selected by a family.* <code>title</code> : This is used when displaying the section on the form and provides the only way to visually tell multiple sections apart. In a marriage you would have a "Husband", a "Wife" and possibly others such as "Witnesses".  <nowiki><section role='Primary' type='person' title='Child'></nowiki> Each section element should contain a <code>column</code> element for each column in the section. Column elements describe information that may be recorded for each person in the section. A column element contains: * An <code>_attribute</code> element. This contains the key used to store column information in the attributes of event reference objects within the Gramps database (The "Type" Attribute of the reference information for the event. If you use "<code>Name</code>" then the selected person's name will be prefilled. Once defined this text must not be changed.* An optional <code>_longname</code> element. This contains a fuller description of the column and is only used for tooltips (when you hover the mouse over the field in the form).* A <code>size</code> element. This contains the size of the column in the census report. It is a percentage of the page width. The sum of all size elements in a definition should total 100%.   <column> <_attribute>At Home</_attribute> <_longname>Working at Home</_longname> <size>6</size> </column> {{man note|Note: The underscore is important|As it indicates that the text should be translated by translators.}} Each form element may optionally contain <code>heading</code> elements. Heading elements describe information that is recorded once for each form. A heading element contains: * An <code>_attribute</code> element. This contains the key used to store information in the attributes of the event objects within the Gramps database.  <heading> <_attribute>City or Borough</_attribute> </heading> Although you can add your definitions to the pre-defined entries in <code>form_xx.xml</code>, it is recommended you create a separate file called <code>custom.xml</code> or <code>test.xml</code> for this purpose. ====Tips on debugging your custom form definitions====After creating or updating a form (in <code>custom.xml</code> or <code>test.xml</code>) to make sure your Form is correctly formatted use a text editor that includes an XML mode and syntax check, (like <code>NotePad++</code> and install the "<code>XML Tools</code>" plugin), then the editor will be able to tell you if your Form's XML code is formatted correctly. If the XML form check worked then start Gramps to test it and if the {{man button|New}} and {{man button|Edit}} buttons don't appear in the {{man label|Forms Gramplet}} then there is a good chance that an XML syntax (or other) error has occurred. The {{man label|Forms Gramplet}} will not tell you where the error is, but luckily you may get a message in <code>grampsXX.log</code> (in the root of gramps user directory) that may look like:  <nowiki>Traceback (most recent call last): File "C:\Program Files\GrampsAIO64-5.1.2\gramps\gen\plug\_manager.py", line 252, in load_plugin _module = self.import_plugin(pdata) ... File "C:\Users\<~username>\AppData\Roaming\gramps\gramps51\plugins\Form\form.py", line 114, in __load_definitions dom = xml.dom.minidom.parse(definition_file) File "AIO/xml/dom/minidom.py", line 1958, in parse File "AIO/xml/dom/expatbuilder.py", line 911, in parse File "AIO/xml/dom/expatbuilder.py", line 207, in parseFile xml.parsers.expat.ExpatError: mismatched tag: line 12, column 10</nowiki> If there are other (non-syntax) errors in the file then when you use the {{man button|New}} button and select the form, it will probably fail and suggest you restart Gramps, if you open the details first you will see some information which may give you a clue as to where the issue is (start from the bottom of the error message), the following is an example:  <nowiki> 25285: ERROR: grampsapp.py: line 157: Unhandled exception ... File "C:\Users\<~username>\AppData\Roaming\gramps\gramps51\plugins\Form\editform.py", line 995, in __init__ title1, title2 = title.split('/')ValueError: not enough values to unpack (expected 2, got 1)</nowiki> For the example error above, the title was fine, the Forms Gramplet was reporting that one of the entries in the custom form was incorrectly typed and should be exactly like the supported [[Addon:Forms_Gramplet#Writing_your_own_form_definitions|form elements]].
=== Submitting your form definitions ===
15,091
edits

Navigation menu