Documentation

CFormOutput class

CFormOutput class is used to handle web form templates

Class implementation area

This class is used to manage visual representation of a web from. When a web form template is displayed, it receives the $FORM variable - initialized class instance. Template is generated as HTML code with included calls of class methods (example see. below). Visual editing of a template, as well as creation of a web form based on a template are available.

Main class methods

Main class methods.

Method Description Available from version
ShowApplyButton Show the "Apply" button.
ShowCaptcha Show CAPTCHA formatted fields.
ShowCaptchaField Show field to enter CAPTCHA text.
ShowCaptchaImage Show CAPTCHA image.
ShowErrorMsg Show the module error messages. Called automatically.
ShowFormDescription Show web form description.
ShowFormErrors Show formatted error list for the form validator.
ShowFormErrorsText Show unformatted list of errors for the form validator.
ShowFormFooter Show HTML code of a web form footer. Inserted at the template footer automatically.
ShowFormHeader Show header of the form HTML code. Inserted at the start of template automatically.
ShowFormImage Show web form image.
ShowFormNote Show formatted web form notes.
ShowFormNoteText Show unformatted web form notes.
ShowFormTitle Show the web form text title.
ShowInput Show web form fields.
ShowInputCaption Show web form field caption.
ShowInputCaptionImage Show web form caption image.
ShowRequired Show "required field" check.
ShowResetButton Show the "Reset" button.
ShowSubmitButton Show web from submit button.
SetInputDefaultValue Set the Default value for the web form field.

Methods to verify conditions. All conventional methods are unavailable in the visual editor mode. They can be used only in the PHP edit mode.

Method Description Available from version
isFormDescription Checks if the web form has description.
isFormErrors Checks if validator errors are present.
isFormImage Checks if the web form has an image.
isFormNote Checks if the web form has notes.
isFormTitle Checks if the web form has text title.
isInputCaptionImage Checks if the web form has caption image field.
isUseCaptcha Checks if CAPTCHA is used in the web form.

Example of web form template

$FORM - CFormOutput class instance - created and initialized automatically externally from a template. Call of the CFormOutput::ShowFormHeader() and CFormOutput::ShowFormFooter() methods is also added automatically to the template.


<!-- Show the web form description -->
<table width="100%" cellpadding="2" cellspacing="0" border="0">
    <tr>
        <td align="center"><?=$FORM->ShowFormDescription()?></td>
    </tr>
</table>

<!-- If validator has errors - show them -->
<?if($FORM->isFormErrors()):?>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
    <tr>
        <td><?=$FORM->ShowFormErrors()?></td>
    </tr>
</table>
<?endif?>

<!-- Show the web form fields -->
<table width="100%" cellpadding="2" cellspacing="0" border="0">
    <tr>
        <td width="40%" valign="top" align="right"><?=$FORM->ShowInputCaption('test_q')?>: </td>
        <td width="60%" valign="top"><?=$FORM->ShowInput('test_q')?></td>
    </tr>
    <tr>
        <td valign="top" align="right"><?=$FORM->ShowInputCaption('test_q_text')?>: </td>
        <td valign="top"><?=$FORM->ShowInput('test_q_text')?></td>
    </tr>
    <tr>
        <td valign="top" align="right"><?=$FORM->ShowInputCaption('test_q_textarea')?>: </td>
        <td valign="top"><?=$FORM->ShowInput('test_q_textarea')?></td>
    </tr>
</table>

<!-- If CAPTCHA is used - show caption image and the input field -->
<?if($FORM->isUseCaptcha()):?>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
    <tr>
        <td colspan="2" height="8"></td>
    </tr>
    <tr>
        <td width="40%" valign="top" align="right" class="text">Protection from automatic registration: </td>
        <td width="60%" valign="top"><?=$FORM->ShowCaptchaImage()?></td>
    </tr>
    <tr>
        <td valign="top" align="right" class="text">Enter the word from the image<?=$FORM->ShowRequired()?>: </td>
        <td valign="top"><?=$FORM->ShowCaptchaField()?></td>
    </tr>
</table>
<?endif?>

<!-- Show the web form buttons -->
<table width="100%" cellpadding="2" cellspacing="0" border="0">
    <tr>
        <td width="40%">&nbsp;</td>
        <td width="60%">
            <?=$FORM->ShowSubmitButton()?>&nbsp;
            <?=$FORM->ShowApplyButton()?>&nbsp;
            <?=$FORM->ShowResetButton()?>
        </td>
    </tr>
</table>

If using editing pages of web form result is not planned as well as viewing list of results, the web form response can be inserted bypassing the main template:


<!-- If the form response is available - enter it and bypass the template -->
<?if($FORM->isFormNote()):?>
<?=$FORM->ShowFormNote()?>
<?else:?>
<!-- here is location of the rest of web form -->
<?endif?>


© «Bitrix24», 2001-2024
Up