Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to auto-attach Fields #42

Open
laceysanderson opened this issue Aug 16, 2023 · 1 comment
Open

How to auto-attach Fields #42

laceysanderson opened this issue Aug 16, 2023 · 1 comment

Comments

@laceysanderson
Copy link
Member

laceysanderson commented Aug 16, 2023

Tripal/Chado Fields are automatically attached to content types using our Tripal Fields Collection service. This service uses a YAML file describing the field settings and content type mapping which should be named yourmodule/config/install/tripal.tripalfield_collection.yourmodule.yml. And example of this file and the one which defines the default fields for chado can be found here: tripal_chado/config/install/tripal.tripalfield_collection.default_chado.yml.

The beginning of the file should look like:

id: 'default_chado'
label: 'Default Chado Fields'
description: 'Default fields configurations provided by the Tripal Chado module'
fields:

Where you replace strings with ones which match your module and intent.

Then below fields: each item is an individual field and described the entity it is attached to and it's settings. For example, the following stanza describes the organism field attached to the gene content type:

    -   name: gene_organism
        content_type: gene
        label: Organism
        type: chado_organism_default
        description: A material entity that is an individual living system, such as animal, plant, bacteria or virus, that is capable of replicating or reproducing, growth and maintenance in the right environment. An organism may be unicellular or made up, like humans, of many billions of cells divided into specialized tissues and organs.
        cardinality: 1
        required: true
        storage_settings:
            storage_plugin_id: chado_storage
            storage_plugin_settings:
                base_table: feature
                base_column: organism_id
        settings:
            termIdSpace: OBI
            termAccession: "0100026"
        display:
          view:
            default:
              region: content
              label: above
              weight: 10
          form:
            default:
              region: content
              weight: 10

The name should be a unique name for this field instance (i.e. must uniquely identify this field attached to the gene) which is why it usually consists of the content type name followed by the field name.

The content_type value must match the machine name of a content type existing on the site. Examples of the default tripal content types can be found here: https://github.com/tripal/tripal/blob/4.x/tripal_chado/config/install/tripal.tripalentitytype_collection.default_chado.yml

The label will be a Human readable string shown to the administrator in the UI. It is also often the field label so be descriptive but also short.

The type should be the id in your fieldtype class annotation.

The storage_settings indicate where your field should store it's data in chado. This is specifically the main store_id and will be further expanded by your properties in the field type addTypes() method.

The display section idicates where in the view or edit form this field should be displayed by default. If this is not set propertly your field will likely be disabled by default which can be confusing!

@dsenalik
Copy link
Contributor

dsenalik commented Jan 9, 2024

The maximum length of the name is 32 characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants