webCOMAND

form::form()

Return HTML <form> code for the object passed to the Constructor.  Form field order is based on the Content Type or corresponding Content Type Settings, if defined.

Prototype

string form(array $options = [])

Parameters

  • options - Any of the following key/value pairs.  In addition, most options accepted by field(), input(), choices() and submit() can also be specified here and will be passed along when appropriate.
    • attributes - An associative array of <form> attributes to override and/or add to the defaults.  If an attribute value is set to NULL, the attribute will be added without a value.
    • no_form_tag - If TRUE, do not include a <form> and </form> tag in the resulting HTML.  In other words, only produce the HTML that will result from field(), for each field.
    • submit_label - Determines the text in the submit button (<input type="submit" /> value attribute), which otherwise defaults to "Submit".
    • allow_updates - Produce a hidden OID field if the form object has an OID set because it exists in the repository.  This will be interpreted by update().

Return

HTML code to represent the object passed to Constructor, including the <form> (unless no_form_tag option is TRUE) and each field, as returned by field().

<form action="" method="POST" enctype="multipart/form-data">
    <div class="field">
        <label>{Field Title}</label>
        <input type="text" name="{FieldIdentifier}" value="{value}" />
    </div>
    <input type="submit" value="Submit" />
</form>

Example

$repo = comand::repo();
$contact = $repo->new_object('Contact');
$form = new \io_comand_web\form($contact);
echo($form->form(['attributes'=>['method'=>'GET']]));

Related

Constructor, field()