getFieldName function

String getFieldName(
  1. String fieldName
)

Removes the model name that is pre-pended to id fields.

ID fields are named <Model_Name>.<Field_Name>, for example "blog.id". This util will remove the model name and return just the field name ("id").

Implementation

String getFieldName(String fieldName) {
  return fieldName.endsWith('.id') ? 'id' : fieldName;
}