webCOMAND

form::value()

Get the value(s) of a field.  If the field is a Data Type field, the value will be returned as a string.  If it is a forward reference, the OID or an array of OIDs of the referenced object(s) will be returned.

Prototype

string value(mixed $field, array $options = [])

Parameters

  • field - A Content Type Field object or Field Identifier string.
  • options - No options are currently recognized.

Return

String or array of strings containing the field value(s).  An OID or array of OIDs will be returned for object reference field values.

Example

$repo = comand::repo();
$contact = $repo->new_object('Contact');
$form = new \io_comand_web\form($contact);
$value = $form->value('ContactType');
$options = '<select>';
foreach($form->choices('ContactType') as $choice) {
    $options .=
        '<option value="' . htmlspecialchars($choice->value) . '"' .
            ($value == $choice->value ? ' selected' : '') . '>' .
        $choice->title .
        '</option>';
}
$options .= '</select>';

Related

input(), field()