Tripal
|
Public Member Functions | |
__construct ($field, $instance=NULL) | |
form (&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) | |
validate ($element, $form, &$form_state, $langcode, $delta) | |
validateDefaults ($element, $form, &$form_state, $langcode, $delta) | |
submit ($form, &$form_state, $entity_type, $entity, $langcode, $delta) | |
theme ($element) | |
Static Public Member Functions | |
static | info () |
Static Public Attributes | |
static | $default_label = 'Tripal Field.' |
static | $field_types = ['no_widget'] |
TripalFieldWidget::__construct | ( | $field, | |
$instance = NULL |
|||
) |
Instantiates a new TripalFieldWidget object.
$field | An array containing the field data as returned by field_info_field() |
$instance | (Optional). Set the instance of this field when one is available. This is necessary when working with instance specific functions such as the formatterSettingsForm, widgetForm, etc. |
Reimplemented in sbo__relationship_widget.
TripalFieldWidget::form | ( | & | $widget, |
& | $form, | ||
& | $form_state, | ||
$langcode, | |||
$items, | |||
$delta, | |||
$element | |||
) |
Provides the form for editing of this field.
This function corresponds to the hook_field_widget_form() function of the Drupal Field API.
This form is diplayed when the user creates a new entity or edits an existing entity. If the field is attached to the entity then the form provided by this function will be displayed.
At a minimum, the form must have a 'value' element. For Tripal, the 'value' element of a field always corresponds to the value that is presented to the end-user either directly on the page (with formatting) or via web services, or some other mechanism. However, the 'value' is sometimes not enough for a field. For example, the Tripal Chado module maps fields to table columns and sometimes those columns are foreign keys therefore, the Tripal Chado modules does not just use the 'value' but adds additional elements to help link records via FKs. But even in this case the 'value' element must always be present in the return form and in such cases it's value should be set equal to that added in the 'load' function.
$widget | |
$form | The form structure where widgets are being attached to. This might be a full form structure, or a sub-element of a larger form. |
$form_state | An associative array containing the current state of the form. |
$langcode | The language associated with $items. |
$items | Array of default values for this field. |
$delta | The order of this item in the array of subelements (0, 1, 2, etc). |
$element | A form element array containing basic properties for the widget:
|
Reimplemented in remote__data_widget, uo__unit_widget, taxrank__infraspecific_taxon_widget, so__transcript_widget, so__genotype_widget, so__cds_widget, sio__vocabulary_widget, sio__references_widget, sio__annotation_widget, sep__protocol_widget, schema__publication_widget, schema__alternate_name_widget, schema__additional_type_widget, sbo__relationship_widget, sbo__phenotype_widget, sbo__database_cross_reference_widget, operation__analysis_widget, ogi__location_on_map_widget, obi__organism_widget, local__source_data_widget, local__contact_widget, go__gene_expression_widget, efo__array_design_widget, data__sequence_record_widget, data__sequence_length_widget, data__sequence_coordinates_widget, data__sequence_checksum_widget, data__sequence_widget, data__protein_sequence_widget, data__accession_widget, chado_linker__prop_widget, chado_linker__contact_widget, and rdfs__type_widget.
|
static |
Provides information about the widgets provided by this field.
This function corresponds to the hook_field_widget_info() function of the Drupal Field API.
This is a static function as it provides default values for all of the widgets for this field type, and thus we don't need an instantiated object to provide this information.
TripalFieldWidget::submit | ( | $form, | |
& | $form_state, | ||
$entity_type, | |||
$entity, | |||
$langcode, | |||
$delta | |||
) |
Performs extra commands when the entity form is submitted.
Drupal typically does not provide a submit hook for fields. The TripalField provides one to allow for behind-the-scenes actions to occur. This function should never be used for updates, deletes or inserts for the Chado table associated with the field. Rather, the storage backend should be allowed to handle inserts, updates deletes. However, it is permissible to perform inserts, updates or deletions within Chado using this function. Those operations can be performed if needed but on other tables not directly associated with the field.
An example is the chado.feature_synonym table. The chado_linker__synonym field allows the user to provide a brand new synonym and it must add it to the chado.synonym table prior to the record in the chado.feature_synonym table. This insert occurs in the widgetFormSubmit function.
$entity_type | The type of $entity. |
$entity | The entity for the operation. |
$field | The field structure for the operation. |
$instance | The instance structure for $field on $entity's bundle. |
$langcode | The language associated with $items. |
$items | $entity->{$field['field_name']}[$langcode], or an empty array if unset. |
$form | The submitted form array. |
$form_state | . The form state array. |
Reimplemented in so__transcript_widget, so__genotype_widget, sio__references_widget, sio__annotation_widget, sep__protocol_widget, schema__alternate_name_widget, sbo__phenotype_widget, sbo__database_cross_reference_widget, ogi__location_on_map_widget, go__gene_expression_widget, data__sequence_length_widget, data__sequence_coordinates_widget, and data__accession_widget.
TripalFieldWidget::theme | ( | $element | ) |
The theme function for the widget.
$element | A form element array containing basic properties for the widget:
|
Reimplemented in sio__annotation_widget, schema__publication_widget, schema__alternate_name_widget, sbo__relationship_widget, sbo__database_cross_reference_widget, and data__accession_widget.
TripalFieldWidget::validate | ( | $element, | |
$form, | |||
& | $form_state, | ||
$langcode, | |||
$delta | |||
) |
Performs validation of the widget form.
Use this validate to ensure that form values are entered correctly.
The 'value' key of this field must be set in the $form_state['values'] array anytime data is entered by the user. It may be the case that there are other fields for helping select a value. In the end those helper fields must be used to set the 'value' field.
TROUBLESHOOTING: If your widget doesn't appear to be saving data, check the following:
chado-[tablename]__[columnname]
keys for all chado columns. Look at the storage backend for more documentation. Reimplemented in remote__data_widget, uo__unit_widget, taxrank__infraspecific_taxon_widget, so__cds_widget, sio__vocabulary_widget, sep__protocol_widget, schema__publication_widget, schema__alternate_name_widget, schema__additional_type_widget, sbo__relationship_widget, sbo__database_cross_reference_widget, operation__analysis_widget, obi__organism_widget, local__source_data_widget, local__contact_widget, efo__array_design_widget, data__sequence_record_widget, data__sequence_checksum_widget, data__sequence_widget, data__accession_widget, chado_linker__prop_widget, and chado_linker__contact_widget.
TripalFieldWidget::validateDefaults | ( | $element, | |
$form, | |||
& | $form_state, | ||
$langcode, | |||
$delta | |||
) |
Performs validation of the widget form when setting defaults.
Use this validate to ensure that form values are entered correctly when a user edits the defaults on the field edit page (available from the "managed fields" section of the Content type page.
Reimplemented in data__sequence_widget, and chado_linker__prop_widget.