New in 1.43.0 (BETA)

useAttributeDefinition()

Returns an attribute definition of the current data.

Returns

attributeDefinition (Array) – An attribute definition of the current data.

Current data is mostly set automatically by the SDK, based on the particular structure and DataLocators of the content in question, but it can also be provided using the Scrivito.ContentTag component with a dataContext prop.

If there current data is available, it is a single-item scope, a schema has been provided and contains an attribute definition for the corresponding attribute, then a non-empty attribute definition is returned. Otherwise, an empty attribute definition is returned.

  • A non-empty attribute definition is a two-element tuple in which the first element is a String representing the type of the attribute in question, (e.g. "string", "enum", etc), and the second element is a configuration object for the attribute in question – the same configuration object that has been provided through the schema via Scrivito.provideDataClass or Scrivito.provideDataItem. In case no configuration object is available, an empty object {} is returned.
  • An empty attribute definition is a tuple in which the first element is undefined, and the second element is an empty object {}.