formHelper::getFormOpen PHP Method

getFormOpen() public method

Begins a form Includes a safety mechanism to prevent re-opening an already-open form
public getFormOpen ( array $args = [] ) : string
$args array
return string
    public function getFormOpen(array $args = array())
    {
        if (!$this->_formopen) {
            if (!isset($args['method'])) {
                $args['method'] = 'post';
            }
            $this->_formopen = array('id' => isset($args['id']) ? $args['id'] : true, 'method' => $args['method']);
            if (!isset($args['action'])) {
                $args['action'] = $_SERVER['REQUEST_URI'];
            }
            if (isset($args['legend'])) {
                $legend = $args['legend'];
                unset($args['legend']);
                if (!isset($args['title'])) {
                    $args['title'] = $legend;
                }
            } else {
                if (isset($args['title'])) {
                    $legend = $args['title'];
                }
            }
            if (isset($args['alert'])) {
                if ($args['alert']) {
                    $alert = is_array($args['alert']) ? implode('<br />', $args['alert']) : $args['alert'];
                }
                unset($args['alert']);
            }
            $return = '<form ' . htmlHelper::formatProperties($args) . '><fieldset>';
            if (isset($legend)) {
                $return .= '<legend>' . $legend . '</legend>';
            }
            if (isset($alert)) {
                $return .= $this->getErrorMessageContainer(isset($args['id']) ? $args['id'] : 'form', $alert);
            }
            return $return;
        } else {
            if (DEBUG_MODE) {
                $errorMsg = 'Invalid usage of ' . __METHOD__ . '() - a form is already open';
                trigger_error($errorMsg, E_USER_NOTICE);
            }
        }
    }

Usage Example

 I8                     I8
 I8                     I8
 I8                     I8
</pre>';
echo '<div id="bodycontent" class="ui-widget-content"><h1 style="float: right;">' . $html->link('http://www.phpmoadmin.com', $phpmoadmin, array('title' => 'phpMoAdmin')) . '</h1>';
if (isset($accessControl) && !isset($_SESSION['user'])) {
    if (isset($_POST['username'])) {
        $_POST = array_map('trim', $_POST);
        if (isset($accessControl[$_POST['username']]) && $accessControl[$_POST['username']] == $_POST['password']) {
            $_SESSION['user'] = $_POST['username'];
        } else {
            $_POST['errors']['username'] = '******';
        }
    }
    if (!isset($_SESSION['user'])) {
        echo $form->getFormOpen();
        echo $html->div($form->getInput(array('name' => 'username', 'focus' => true)));
        echo $html->div($form->getInput(array('type' => 'password', 'name' => 'password')));
        echo $html->div($form->getInput(array('type' => 'submit', 'value' => 'Login', 'class' => 'ui-state-hover')));
        echo $form->getFormClose();
        exit(0);
    }
}
echo '<div id="dbcollnav">';
$formArgs = array('method' => 'get');
if (isset($mo->mongo['repairDb'])) {
    $formArgs['alert'] = isset($mo->mongo['repairDb']['ok']) && $mo->mongo['repairDb']['ok'] ? 'Database has been repaired and compacted' : 'Database could not be repaired';
}
echo $form->getFormOpen($formArgs);
echo $html->div($form->getSelect(array('name' => 'db', 'options' => $mo->mongo['dbs'], 'label' => '', 'value' => $db, 'addBreak' => false)) . $form->getInput(array('type' => 'submit', 'value' => 'Change database', 'class' => 'ui-state-hover')) . ' <span style="font-size: xx-large;">' . get::htmlentities($db) . '</span> [' . $html->link("javascript: mo.repairDatabase('" . get::htmlentities($db) . "'); void(0);", 'repair database') . '] [' . $html->link("javascript: mo.dropDatabase('" . get::htmlentities($db) . "'); void(0);", 'drop database') . ']');
echo $form->getFormClose() . $html->jsInline('var mo = {}
All Usage Examples Of formHelper::getFormOpen