Skip to content
Snippets Groups Projects
dynamic-form.tmpl.php 2.04 KiB
Newer Older
Jared Hancock's avatar
Jared Hancock committed
<?php
    // Form headline and deck with a horizontal divider above and an extra
    // space below.
    // XXX: Would be nice to handle the decoration with a CSS class
    ?>
    <tr><td colspan="2"><hr />
    <div class="form-header" style="margin-bottom:0.5em">
    <h3><?php echo Format::htmlchars($form->getTitle()); ?></h3>
    <div><?php echo Format::display($form->getInstructions()); ?></div>
Jared Hancock's avatar
Jared Hancock committed
    </div>
    </td></tr>
    <?php
    // Form fields, each with corresponding errors follows. Fields marked
    // 'private' are not included in the output for clients
    global $thisclient;
    foreach ($form->getFields() as $field) {
        if (isset($options['mode']) && $options['mode'] == 'create') {
            if (!$field->isVisibleToUsers() && !$field->isRequiredForUsers())
                continue;
        }
        elseif (!$field->isVisibleToUsers() && !$field->isEditableToUsers()) {
Jared Hancock's avatar
Jared Hancock committed
            continue;
Jared Hancock's avatar
Jared Hancock committed
        ?>
            <td colspan="2" style="padding-top:10px;">
            <?php if (!$field->isBlockLevel()) { ?>
                <label for="<?php echo $field->getFormName(); ?>"><span class="<?php
                    if ($field->isRequiredForUsers()) echo 'required'; ?>">
                <?php echo Format::htmlchars($field->getLocal('label')); ?>
            <?php if ($field->isRequiredForUsers()) { ?>
                <span class="error">*</span>
            ?></span><?php
                if ($field->get('hint')) { ?>
                    <br /><em style="color:gray;display:inline-block"><?php
                        echo Format::viewableImages($field->getLocal('hint')); ?></em>
            $field->render(array('client'=>true));
            ?></label><?php
Jared Hancock's avatar
Jared Hancock committed
            foreach ($field->errors() as $e) { ?>
                <div class="error"><?php echo $e; ?></div>
            $field->renderExtras(array('client'=>true));
Jared Hancock's avatar
Jared Hancock committed
            </td>
        </tr>
        <?php
    }
?>