0) { self::addTextElement($entry['visibleName'], $entry['valueName'], $entry['icon'], $user[$entry['valueName']]); } else { self::addTextElement($entry['visibleName'], $entry['valueName'], $entry['icon']); } } foreach(self::FORM_CREATE_PASSWORD as $entry) { if(sizeof($user) > 0) { self::addPasswordElement($entry['visibleName'], $entry['valueName'], $entry['icon'], $user['user_pass']); } else { self::addPasswordElement($entry['visibleName'], $entry['valueName'], $entry['icon']); } } self::closeHalfWidthElement(); self::closeHalfWidthElement(); self::openHalfWidthElement('Konto Informationen'); self::openInnerHalfWithElement(); foreach(self::FORM_CREATE_ACCOUNT as $entry) { if(sizeof($user) > 0) { self::addTextElement($entry['visibleName'], $entry['valueName'], $entry['icon'], $user[$entry['valueName']]); } else { self::addTextElement($entry['visibleName'], $entry['valueName'], $entry['icon']); } } if(sizeof($user) > 0) { self::addSelectDropdown($acl->loadAclRoles(), 'lock', $user['user_role_id']); self::addActiveCheckbox('Konto aktivieren', $user['user_account_active']); } else { self::addSelectDropdown($acl->loadAclRoles(), 'lock'); self::addActiveCheckbox('Konto aktivieren', true); } self::closeHalfWidthElement(); if(sizeof($user) > 0) { self::addHiddenElementEditUser($user); self::addSubmitFormButton('Speichern', 'save-alt'); } else { self::addHiddenElementNewUser(); self::addSubmitFormButton('Erstellen', 'save-alt'); } self::closeHalfWidthElement(); return Form::addForm([ 'name' => 'userForm', 'action' => $action, 'class' => 'row', 'method' => 'post', 'target' => '_self' ]); } private static function addHiddenElementNewUser() { Form::addTypeHidden([ 'name' => 'user_new', 'value' => 1 ]); Form::addTypeHidden([ 'name' => 'user_active', 'value' => 1 ]); } private static function addHiddenElementEditUser(array $user = []) { Form::addTypeHidden([ 'name' => 'user_edit', 'value' => 1 ]); Form::addTypeHidden([ 'name' => 'user_active', 'value' => $user['user_account_active'] ]); Form::addTypeHidden([ 'name' => 'user_id', 'value' => $user['uid'] ]); } private static function addSubmitFormButton(string $buttonText = '', string $icon = '') { Form::addOpenDiv([ 'class' => 'box-footer text-end', 'value' => '' ]); Form::addTypeButton([ 'class' => 'btn btn-primary', 'type' => 'submit', 'value' => ' '.$buttonText ]); Form::addCloseDiv(); } /** * @desc will add a text element to the form * @param string $visibleName * @param string $valueName * @param string $icon * @return void */ private static function addTextElement(string $visibleName = '', string $valueName = '', string $icon = '', string $value = '') { Form::addTypeLabel([ 'class' => 'form-label', 'for' => $valueName, 'value' => $visibleName ]); Form::addOpenDiv([ 'class' => 'input-group mb-3', 'value' => '' ]); Form::addOpenAny([ 'any' => 'span', 'class' => 'input-group-text', 'value' => '' ]); Form::addCloseAny([ 'any' => 'span' ]); if($value!="") { Form::addInputTypeText([ 'class' => 'form-control', 'name' => $valueName, 'placeholder' => $visibleName, 'value' => $value ]); } else { Form::addInputTypeText([ 'class' => 'form-control', 'name' => $valueName, 'placeholder' => $visibleName ]); } Form::addCloseDiv(); } /** * @desc will add a select dropdown to the form * @param array $options * @param string $icon * @return void */ private static function addSelectDropdown( array $options = [], string $icon = '', int $selected = 0 ) { Form::addTypeLabel([ 'for' => 'source-api', 'class' => 'form-label', 'value' => 'Rolle auswählen:' ]); Form::addOpenDiv([ 'class' => 'input-group mb-3', 'value' => '' ]); Form::addOpenAny([ 'any' => 'span', 'class' => 'input-group-text', 'value' => '' ]); Form::addCloseAny([ 'any' => 'span' ]); foreach($options as $option) { if($selected == $option['acl_id']) { Form::addSelectOption([ 'context' => $option['acl_role'], 'value' => $option['acl_id'], 'selected' => 'selected' ]); } else { Form::addSelectOption([ 'context' => $option['acl_role'], 'value' => $option['acl_id'] ]); } } Form::addSelect([ 'name' => 'user_acl_id', 'class' => 'form-control select2' ]); Form::addCloseDiv(); } /** * @desc will add a password element to the form * @param string $visibleName * @param string $valueName * @param string $icon * @return void */ private static function addPasswordElement(string $visibleName = '', string $valueName = '', string $icon = '', string $value = '') { Form::addTypeLabel([ 'class' => 'form-label', 'for' => $valueName, 'value' => $visibleName ]); Form::addOpenDiv([ 'class' => 'input-group mb-3', 'value' => '' ]); Form::addOpenAny([ 'any' => 'span', 'class' => 'input-group-text', 'value' => '' ]); Form::addCloseAny([ 'any' => 'span' ]); if($value!="") { Form::addInputTypePassword([ 'class' => 'form-control', 'name' => $valueName, 'placeholder' => $visibleName, 'value' => $value ]); } else { Form::addInputTypePassword([ 'class' => 'form-control', 'name' => $valueName, 'placeholder' => $visibleName ]); } Form::addCloseDiv(); } /** * @desc will open a half width element for form fields * @param string $title * @return void */ private static function openHalfWidthElement(string $title = '') { Form::addOpenDiv([ 'class' => 'col-lg-6 col-13', 'value' => '' ]); Form::addOpenDiv([ 'class' => 'box', 'value' => '' ]); Form::addOpenDiv([ 'class' => 'box-header with-border', 'value' => '