Commit 1e336417 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Single FE rendered with BS style. No save.

parent 2b2b0099
Pipeline #2394 passed with stages
in 2 minutes and 44 seconds
......@@ -240,16 +240,30 @@ abstract class AbstractBuildForm {
$filter = $this->getProcessFilter();
if ($this->formSpec['multiMode'] !== 'none') {
$parentRecords = $this->dbArray[$this->dbIndexQfq]->sql($this->formSpec['multiSql']);
foreach ($parentRecords as $row) {
$this->store->setStore($row, STORE_PARENT_RECORD, true);
$jsonTmp = array();
$htmlElements = $this->elements($row['_id'], $filter, 0, $jsonTmp, $modeCollectFe);
$json[] = $jsonTmp;
}
if ($this->formSpec[F_MULTI_SQL] !== '') {
$parentRecords = $this->evaluate->parse($this->formSpec[F_MULTI_SQL], ROW_REGULAR);
if (!empty($parentRecords)) {
// Check for 'id' or '_id' as column name
$idName = F_MULTI_COL_ID;
if (isset($parentRecords[0]['_' . F_MULTI_COL_ID])) {
$idName = '_' . F_MULTI_COL_ID;
}
// Check that an column 'id' is given
if (!isset($parentRecords[0][$idName])) {
throw new \UserFormException(
json_encode([ERROR_MESSAGE_TO_USER => 'Missing column "_' . F_MULTI_COL_ID . '"', ERROR_MESSAGE_TO_DEVELOPER => $this->formSpec[F_MULTI_SQL]]),
ERROR_INVALID_OR_MISSING_PARAMETER);
}
foreach ($parentRecords as $row) {
$this->store->setStore($row, STORE_PARENT_RECORD, true);
$jsonTmp = array();
$htmlElements .= $this->elements($row[$idName], $filter, 0, $jsonTmp, $modeCollectFe);
$json[] = $jsonTmp;
}
}
} else {
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
......
......@@ -165,7 +165,7 @@ const ERROR_USER_NOT_LOGGED_IN = 1017;
const ERROR_USER_LOGGED_IN = 1018;
const ERROR_FORM_FORBIDDEN = 1019;
const ERROR_FORM_UNKNOWN_PERMISSION_MODE = 1020;
const ERROR_MULTI_SQL_MISSING = 1021;
const ERROR_TOKEN_MISSING = 1022;
const ERROR_RECURSION_TOO_DEEP = 1023;
const ERROR_CHECKBOXMODE_UNKNOWN = 1024;
......@@ -926,6 +926,8 @@ const F_EXTRA_DELETE_FORM = 'extraDeleteForm';
const F_FINAL_DELETE_FORM = 'finalDeleteForm';
const F_DIRTY_MODE = 'dirtyMode';
const F_NOTE_INTERNAL = 'noteInternal';
const F_MULTI_SQL = 'multiSql';
const F_MULTI_COL_ID = 'id';
const F_SUBMIT_BUTTON_TEXT = 'submitButtonText';
const F_BUTTON_ON_CHANGE_CLASS = 'buttonOnChangeClass';
......
......@@ -1006,7 +1006,7 @@ class QuickFormQuery {
unset($form[F_PARAMETER]);
// Save specific elements to be expanded later.
$parseLater = OnArray::getArrayItems($form, [F_FORWARD_PAGE, FE_FILL_STORE_VAR, F_REST_SQL_LIST, F_REST_SQL_DATA]);
$parseLater = OnArray::getArrayItems($form, [F_FORWARD_PAGE, FE_FILL_STORE_VAR, F_REST_SQL_LIST, F_REST_SQL_DATA, F_MULTI_SQL]);
$form[FE_FILL_STORE_VAR] = '';
$form[F_FORWARD_PAGE] = '';
$form[F_REST_SQL_LIST] = '';
......@@ -1532,11 +1532,6 @@ class QuickFormQuery {
}
}
// Form Definition valid?
if ($this->formSpec['multiMode'] !== 'none' && $this->formSpec['multiSql'] === '') {
throw new \UserFormException("MultiMode selected, but MultiSQL missing", ERROR_MULTI_SQL_MISSING);
}
if ($formMode === FORM_DELETE) {
return $sipFound;
}
......
......@@ -74,9 +74,9 @@ class Save {
public function process() {
$rc = 0;
if ($this->formSpec['multiMode'] !== 'none') {
if ($this->formSpec[F_MULTI_SQL] !== '') {
$parentRecords = $this->db->sql($this->formSpec['multiSql']);
$parentRecords = $this->db->sql($this->formSpec[F_MULTI_SQL]);
foreach ($parentRecords as $row) {
$this->store->setStore($row, STORE_PARENT_RECORD, true);
$rc = $this->elements($row['_id']);
......
......@@ -178,7 +178,7 @@ VALUES (1, 1, 'basic', 'Basic', 'show', 'pill', 'all', 'container', 100, 0, '',
''),
(3, 1, 'layout', 'Layout', 'show', 'pill', 'all', 'container', 300, 0, '', '', '', '', '', 0, '', '', ''),
(4, 1, 'access', 'Access', 'show', 'pill', 'all', 'container', 400, 0, '', '', '', '', '', 0, '', '', ''),
(5, 1, 'multi', 'Multi', 'hidden', 'pill', 'all', 'container', 500, 0, '', '', '', '', '', 0, '', '', '');
(5, 1, 'multi', 'Multi', 'show', 'pill', 'all', 'container', 500, 0, '', '', '', '', '', 0, '', '', '');
# FormEditor: FormElements for 'form'
INSERT INTO FormElement (formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value,
......@@ -299,7 +299,8 @@ VALUES
# Multi
(1, 'multi', 'Multi', 'show', 'fieldset', 'all', 'native', 510, 0, 0, '', '', '', '', '', 5, '', '', '',
'specialchar', 'no', ''),
(1, 'multiMode', 'Multi Mode', 'show', 'radio', 'all', 'native', 520, 0, 0, '', '', '', '', '', 5, '', '', '',
(1, 'multiMode', 'Multi Mode', 'show', 'radio', 'all', 'native', 520, 0, 0, '', '', '', '', 'buttonClass', 5, '', '',
'',
'specialchar', 'no', ''),
(1, 'multiSql', 'Multi SQL', 'show', 'text', 'all', 'native', 530, '80,2,15', 0, '', '', '', '', '', 5, '', '', '',
'none', 'no', ''),
......
......@@ -672,7 +672,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
'permitUrlParameter' => '',
'render' => 'bootstrap',
'multiMode' => 'none',
'multiSql' => '',
F_MULTI_SQL => '',
'multiDetailForm' => '',
'multiDetailFormParameter' => '',
F_FORWARD_MODE => 'auto',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment