', $pill);
$html .= $this->getFormTag();
$class = ['tab-content', $this->formSpec[F_CLASS_BODY]];
if ($pill == '') {
$class[] = 'col-md-12';
}
$html .= "
";
return $html;
}
/**
* Build Buttons panel on top right corner of form.
* Simulate Submit Button: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml
*
* @return string
*/
private function buildButtons() {
$buttonNew = '';
$buttonDelete = '';
$buttonClose = '';
$buttonSave = '';
$buttonEditForm = '';
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
// Button: FormEdit
if ($this->showDebugInfo) {
$toolTip = "Edit form" . PHP_EOL . PHP_EOL . OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'");
$url = $this->createFormEditorUrl(FORM_NAME_FORM, $this->formSpec[F_ID]);
$buttonEditForm = $this->buildButtonAnchor('form-edit-button', $url, $toolTip, GLYPH_ICON_TOOL);
}
// Button: Save
if (Support::findInSet(FORM_BUTTON_SAVE, $this->formSpec['showButton']) && $this->formSpec[F_SUBMIT_BUTTON_TEXT] === '') {
$toolTip = 'Save';
if ($this->showDebugInfo) {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$buttonSave = $this->buildButtonCode('save-button', $toolTip, GLYPH_ICON_CHECK, '', $this->formSpec[F_BUTTON_ON_CHANGE_CLASS]);
}
// Button: Close
if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec['showButton'])) {
$toolTip = 'Close';
$buttonClose = $this->buildButtonCode('close-button', 'Close', GLYPH_ICON_CLOSE);
}
// Button: Delete
if (Support::findInSet(FORM_BUTTON_DELETE, $this->formSpec['showButton'])) {
$toolTip = 'Delete';
if ($this->showDebugInfo && $recordId > 0) {
$toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_FINAL_DELETE_FORM] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$disabled = ($recordId > 0) ? '' : 'disabled';
$buttonDelete = $this->buildButtonCode('delete-button', $toolTip, GLYPH_ICON_DELETE, $disabled);
}
// Button: New
if (Support::findInSet(FORM_BUTTON_NEW, $this->formSpec['showButton'])) {
$toolTip = 'New';
$url = $this->deriveNewRecordUrlFromExistingSip($toolTip);
$buttonNew = $this->buildButtonAnchor('form-new-button', $url, $toolTip, GLYPH_ICON_NEW);
}
// Arrangement: Edit Form / Save / Close / Delete / New
// Specified in reverse order cause 'pull-right' inverts the order. http://getbootstrap.com/css/#helper-classes-floats
$html = '';
$html .= Support::wrapTag('
', $buttonNew);
$html .= Support::wrapTag('
', $buttonDelete);
$html .= Support::wrapTag('
', $buttonSave . $buttonClose);
$html .= Support::wrapTag('
', $buttonEditForm);
$html = Support::wrapTag('
', $html);
return $html;
}
/**
* @param $id
* @param $url
* @param $title
* @param $icon
* @param string $disabled
* @return string
*/
private function buildButtonAnchor($id, $url, $title, $icon, $disabled = '') {
return "
";
}
/**
* Creates a button with the given attributes. If there is no $icon given, render the button without glyph.
*
* @param string $id
* @param string $title
* @param string $icon
* @param string $disabled
* @return string
*/
private function buildButtonCode($id, $title, $icon, $disabled = '', $buttonOnChangeClass = '') {
$element = "
";
$classAdd = "navbar-btn";
if ($icon === '') {
$element = $title;
$classAdd = '';
}
$class = Support::doAttribute('class', ["btn btn-default", $classAdd]);
$onChange = Support::doAttribute('data-class-on-change', $buttonOnChangeClass);
$title = Support::doAttribute('title', $title);
return "
$element ";
}
/**
* @param $pillArray
* @return string
* @throws UserFormException
*/
private function buildPillNavigation($pillArray) {
$pillButton = '';
$pillDropdown = '';
$htmlDropdown = '';
if ($pillArray == null)
return '';
$maxVisiblePill = (isset($this->formSpec['maxVisiblePill']) && $this->formSpec['maxVisiblePill'] !== '') ? $this->formSpec['maxVisiblePill'] : 1000;
// Iterate over all 'pill'
$ii = 0;
$active = 'class="active"';
foreach ($pillArray as $formElement) {
$ii++;
if ($formElement[FE_NAME] === '' || $formElement[FE_LABEL] === '') {
$this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($formElement), STORE_SYSTEM);
$this->store->setVar(SYSTEM_FORM_ELEMENT_COLUMN, 'name, label', STORE_SYSTEM);
throw new UserFormException("Field 'name' and/or 'label' are empty", ERROR_NAME_LABEL_EMPTY);
}
// Anker for pill navigation
$a = '
createAnker($formElement['id'])) . ' data-toggle="tab">' . $formElement[FE_LABEL] . ' ';
if ($ii <= $maxVisiblePill) {
$pillButton .= '
' . $a . ' ';
} else {
$pillDropdown .= '
' . $a . ' ';
}
$active = '';
}
// Pill Dropdown necessary?
if ($ii > $maxVisiblePill) {
$htmlDropdown = Support::wrapTag('