webCOMAND

cObject::enum()

Gets the Title of the selected choice of a given field, for a field with Choices.

Returns the Title of the selected choice as a string.  If no choice is selected, NULL is returned.  If an "Other" choice is filled in, the value is returned as a string.

Field choices are defined from the Appearance tab in the Edit Field sidebar of the Content Type Editor View.

Prototype

string enum(mixed $field)

Parameters

  • field - Field to get the selected Title for.  It may be provided as an Identifier or Content Type Field.  If not specified, objects that reference this object via any forward reference field will be included in the collection.

Return

Returns the Title of the selected choice as a string.  If no choice is selected, NULL is returned.  If an "Other" choice is filled in, the value is returned as a string.

Example

$repo = \comand::repo();
$contact = $repo->get_first('FROM Contact');

// get all contacts this contact is an Emergency Contact for
$contact_type = $contact->enum('ContactType');
echo("$contact is a $contact_type contact.\n");

Related

cTemplate #ENUM, cQL ENUM()