getLabel method

String getLabel(
  1. String attribute
)

Get a human-readable label for a form attribute.

The getLabel function is used to retrieve a human-readable label for a specific form attribute. It first looks up the attribute in the labels map to find a custom label. If a custom label is not found, it generates a label based on the attribute's identifier by replacing underscores with spaces and capitalizing the first letter of each word.

Parameters:

  • attribute: The identifier of the form attribute for which you want to retrieve a label.

Returns: A human-readable label for the specified form attribute.

Implementation

String getLabel(String attribute) {
  String label = labels[attribute] ?? '';
  if (label.isEmpty) {
    label = attribute;
    label = label.replaceAll('_', ' ');
    label = _capitalize(label);
  }

  return label;
}