function getHtml() { $this->updateRequiredText($this->requiredText); // Create the form $jFormElement = new JFormElement('form', array('id' => $this->id, 'target' => $this->id . '-iframe', 'enctype' => 'multipart/form-data', 'method' => 'post', 'class' => $this->class, 'action' => $this->action)); if (!empty($this->onMouseOver)) { $formJFormElement->attr('onmouseover', $this->onMouseOver); } if (!empty($this->onMouseOut)) { $formJFormElement->attr('onmouseout', $this->onMouseOut); } // Set the style if (!empty($this->style)) { $jFormElement->addToAttribute('style', $this->style); } // Global messages if ($this->alertsEnabled) { $jFormerAlertWrapperDiv = new JFormElement('div', array('class' => 'jFormerAlertWrapper', 'style' => 'display: none;')); $alertDiv = new JFormElement('div', array('class' => 'jFormerAlert')); $jFormerAlertWrapperDiv->insert($alertDiv); $jFormElement->insert($jFormerAlertWrapperDiv); } // If a splash is enabled if ($this->splashPageEnabled) { // Create a splash page div $splashPageDiv = new JFormElement('div', array('id' => $this->id . '-splash-page', 'class' => 'jFormerSplashPage jFormPage')); // Set defaults if they aren't set if (!isset($this->splashPage['content'])) { $this->splashPage['content'] = ''; } if (!isset($this->splashPage['splashButtonText'])) { $this->splashPage['splashButtonText'] = 'Begin'; } $splashPageDiv->insert('<div class="jFormerSplashPageContent">' . $this->splashPage['content'] . '</div>'); // Create a splash button if there is no custom button ID if (!isset($this->splashPage['customButtonId'])) { $splashLi = new JFormElement('li', array('class' => 'splashLi')); $splashButton = new JFormElement('button', array('class' => 'splashButton')); $splashButton->update($this->splashPage['splashButtonText']); $splashLi->insert($splashButton); } } // Add a title to the form if (!empty($this->title)) { $title = new JFormElement('div', array('class' => $this->titleClass)); $title->update($this->title); $jFormElement->insert($title); } // Add a description to the form if (!empty($this->description)) { $description = new JFormElement('div', array('class' => $this->descriptionClass)); $description->update($this->description); $jFormElement->insert($description); } // Add the page navigator if enabled if ($this->pageNavigatorEnabled) { $pageNavigatorDiv = new JFormElement('div', array('class' => 'jFormPageNavigator')); if (isset($this->pageNavigator['position']) && $this->pageNavigator['position'] == 'right') { $pageNavigatorDiv->addToAttribute('class', ' jFormPageNavigatorRight'); } else { $pageNavigatorDiv->addToAttribute('class', ' jFormPageNavigatorTop'); } $pageNavigatorUl = new JFormElement('ul', array()); $jFormPageArrayCount = 0; foreach ($this->jFormPageArray as $jFormPageKey => $jFormPage) { $jFormPageArrayCount++; $pageNavigatorLabel = new JFormElement('li', array('id' => 'navigatePage' . $jFormPageArrayCount, 'class' => 'jFormPageNavigatorLink')); // If the label is numeric if (isset($this->pageNavigator['label']) && $this->pageNavigator['label'] == 'numeric') { $pageNavigatorLabelText = 'Page ' . $jFormPageArrayCount; } else { // Add a link prefix if there is a title if (!empty($jFormPage->title)) { $pageNavigatorLabelText = '<span class="jFormNavigatorLinkPrefix">' . $jFormPageArrayCount . '</span> ' . strip_tags($jFormPage->title); } else { $pageNavigatorLabelText = 'Page ' . $jFormPageArrayCount; } } $pageNavigatorLabel->update($pageNavigatorLabelText); if ($jFormPageArrayCount != 1) { $pageNavigatorLabel->addToAttribute('class', ' jFormPageNavigatorLinkLocked'); } else { $pageNavigatorLabel->addToAttribute('class', ' jFormPageNavigatorLinkUnlocked jFormPageNavigatorLinkActive'); } $pageNavigatorUl->insert($pageNavigatorLabel); } // Add the page navigator ul to the div $pageNavigatorDiv->insert($pageNavigatorUl); $jFormElement->insert($pageNavigatorDiv); } // Add the jFormerControl UL $jFormerControlUl = new JFormElement('ul', array('class' => 'jFormerControl')); // Create the cancel button if ($this->cancelButton) { $cancelButtonLi = new JFormElement('li', array('class' => 'cancelLi')); $cancelButton = new JFormElement('button', array('class' => $this->cancelButtonClass)); $cancelButton->update($this->cancelButtonText); if (!empty($this->cancelButtonOnClick)) { $cancelButton->attr('onclick', $this->cancelButtonOnClick); } $cancelButtonLi->append($cancelButton); } // Create the previous button $previousButtonLi = new JFormElement('li', array('class' => 'previousLi', 'style' => 'display: none;')); $previousButton = new JFormElement('button', array('class' => 'previousButton')); $previousButton->update('Previous'); $previousButtonLi->insert($previousButton); // Create the next button $nextButtonLi = new JFormElement('li', array('class' => 'nextLi')); $nextButton = new JFormElement('button', array('class' => 'nextButton')); $nextButton->update($this->submitButtonText); // Don't show the next button if ($this->splashPageEnabled) { $nextButtonLi->setAttribute('style', 'display: none;'); } $nextButtonLi->insert($nextButton); // Add a splash page button if it exists if (isset($splashLi)) { $jFormerControlUl->insert($splashLi); } // Add the previous and next buttons $jFormerControlUl->insert($previousButtonLi); if ($this->cancelButton && $this->cancelButtonLiBeforeNextButtonLi) { echo 'one'; $jFormerControlUl->insert($cancelButtonLi); $jFormerControlUl->insert($nextButtonLi); } else { if ($this->cancelButton) { echo 'two'; $jFormerControlUl->insert($nextButtonLi); $jFormerControlUl->insert($cancelButtonLi); } else { $jFormerControlUl->insert($nextButtonLi); } } // Create the page wrapper and scrollers $jFormPageWrapper = new JFormElement('div', array('class' => 'jFormPageWrapper')); $jFormPageScroller = new JFormElement('div', array('class' => 'jFormPageScroller')); // Add a splash page if it exists if (isset($splashPageDiv)) { $jFormPageScroller->insert($splashPageDiv); } // Add the form pages to the form $jFormPageCount = 0; foreach ($this->jFormPageArray as $jFormPage) { // Hide everything but the first page if ($jFormPageCount != 0 || $jFormPageCount == 0 && $this->splashPageEnabled) { $jFormPage->style .= 'display: none;'; } $jFormPageScroller->insert($jFormPage); $jFormPageCount++; } // Page wrapper wrapper $pageWrapperContainer = new JFormElement('div', array('class' => 'jFormWrapperContainer')); // Insert the page wrapper and the jFormerControl UL to the form $jFormElement->insert($pageWrapperContainer->insert($jFormPageWrapper->insert($jFormPageScroller) . $jFormerControlUl)); // Create a script tag to initialize jFormer JavaScript $script = new JFormElement('script', array('type' => 'text/javascript', 'language' => 'javascript')); // Update the script tag $script->update('$(document).ready(function () { ' . $this->id . 'Object = new JFormer(\'' . $this->id . '\', ' . json_encode($this->getOptions()) . '); });'); $jFormElement->insert($script); // Add a hidden iframe to handle the form posts $iframe = new JFormElement('iframe', array('id' => $this->id . '-iframe', 'name' => $this->id . '-iframe', 'class' => 'jFormerIFrame', 'frameborder' => 0, 'src' => '/empty.html')); if ($this->debugMode) { $iframe->addToAttribute('style', 'display:block;'); } $jFormElement->insert($iframe); // After control if (!empty($this->afterControl)) { $subSubmitInstructions = new JFormElement('div', array('class' => 'jFormerAfterControl')); $subSubmitInstructions->update($this->afterControl); $jFormElement->insert($subSubmitInstructions); } return $jFormElement; }