webCOMAND

form::attributes()

Return HTML tag attributes in string format based on an associative array of attribute key/value pairs.

Prototype

string attributes(array $attributes)

Parameters

  • attributes - Associative array of key/value pairs, where the key is the attribute name and the value is the value, which will be put in quotes.  If an attribute value is set to NULL, the attribute will be added without a value.

Return

String containing the specified attributes as they should appear in HTML source code.  Values will be converted with PHP's built-in htmlspecialchars() before they are output as the quoted value.

Example

$repo = comand::repo();
$contact = $repo->new_object('Contact');
$form = new \io_comand_web\form($contact);
echo('<input' .
    \io_comand_web\form::attributes([
        'type'=>'text',
        'class'=>'test'
    ]) .
    ' />');