From 27bf622663403d53eba16e01eda9f9d1aa23d13d Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Fri, 22 Sep 2023 15:33:27 +0200 Subject: [PATCH] add textarea --- public_html/classes/render-adminlte.class.php | 89 +++++++++++++++---- 1 file changed, 71 insertions(+), 18 deletions(-) diff --git a/public_html/classes/render-adminlte.class.php b/public_html/classes/render-adminlte.class.php index 3eabfc7..b2ac071 100755 --- a/public_html/classes/render-adminlte.class.php +++ b/public_html/classes/render-adminlte.class.php @@ -418,6 +418,8 @@ class renderadminlte { 'values'=>[ 'text'=>'text', 'password'=>'password', + 'email'=>'email', + 'hidden'=>'hidden', 'button'=>'button', 'checkbox'=>'checkbox', @@ -430,12 +432,14 @@ class renderadminlte { 'image'=>'image', 'month'=>'month', 'number'=>'number', + 'password'=>'password', 'radio'=>'radio', 'range'=>'range', 'reset'=>'reset', 'search'=>'search', 'submit'=>'submit', 'tel'=>'tel', + 'text'=>'text', 'time'=>'time', 'url'=>'url', 'week'=>'week', @@ -1183,6 +1187,15 @@ class renderadminlte { } + + public function getHorizontalFormElement($sInput, $sLabel=false, $sId=false){ + return '<div class="form-group row">' + . '<label for="' . $sId . '" class="col-sm-2 col-form-label">' . $sLabel . '</label>' + . '<div class="col-sm-10">'.$sInput.'</div>' + . '</div>' + ; + } + /** * return a text input field: * https://adminlte.io/themes/v3/pages/forms/general.html @@ -1193,32 +1206,25 @@ class renderadminlte { * content * - label - label tag * - name - name attribute for sending form - * - value - value in + * - value - value in field * @return string */ - public function GetInput($aOptions){ - $aOptions=$this->_ensureOptions('input', $aOptions); + public function GetFormInput($aOptions){ + // $aOptions=$this->_ensureOptions('input', $aOptions); $aElement=$aOptions; $aElement['class']='' - . $this->_addClassValue($aOptions['class'], '') + . 'form-control ' + . (isset($aOptions['class']) ? $aOptions['class']: '') ; $sFormid=(isset($aOptions['id']) ? $aOptions['id'] : (isset($aOptions['name']) ? $aOptions['name'] : 'field' ).'-'.md5(microtime(true)) ); - $sLabel=''; + $sLabel=isset($aOptions['label']) ? $aOptions['label'] : ''; $sPrepend=''; $sAppend=''; - $sLabel.=isset($aOptions['label']) && $aOptions['label'] ? $this->_tag('label', ['for'=>$sFormid], $aOptions['label']) : ''; - - $aElement['id']=$sFormid; - foreach(['_infos', 'label'] as $sDeleteKey){ - unset($aElement[$sDeleteKey]); - } - - $sWrapperclass='form-group'; if(isset($aOptions['prepend']) && $aOptions['prepend']){ $sWrapperclass='input-group'; @@ -1232,12 +1238,59 @@ class renderadminlte { $this->_tag('span', ['class'=>'input-group-text'] , $aOptions['append']) ); } - return $this->_tag('div', ['class'=>$sWrapperclass], - $sLabel - .$sPrepend - .$this->_tag('input', $aElement, '', false) - .$sAppend + + $aElement['id']=$sFormid; + foreach(['_infos', 'label', 'append', 'prepend', 'debug'] as $sDeleteKey){ + if(isset($aElement[$sDeleteKey])){ + unset($aElement[$sDeleteKey]); + } + } + + return $this->getHorizontalFormElement( + $sPrepend.$this->_tag('input', $aElement, '', false).$sAppend, + $sLabel, + $sFormid ); } + /** + * return a textare field .. or html editor using summernote + * @param type $aOptions hash with keys for all options + * styling: + * - type - field type: [none]|html + * content + * - label - label tag + * - name - name attribute for sending form + * - value - value in + * @return string + */ + + public function getFormTextarea($aOptions){ + // $aOptions=$this->_ensureOptions('textarea', $aOptions); + $aElement=$aOptions; + $aElement['class']='' + . 'form-control ' + . ((isset($aOptions['type']) && $aOptions['type']=='html' )? 'summernote ': '') + . (isset($aOptions['class']) ? $aOptions['class']: '') + ; + + $sLabel=isset($aOptions['label']) ? $aOptions['label'] : ''; + $sFormid=(isset($aOptions['id']) + ? $aOptions['id'] + : (isset($aOptions['name']) ? $aOptions['name'] : 'field' ).'-'.md5(microtime(true)) + ); + $value=isset($aOptions['value']) ? $aOptions['value']: ''; + foreach(['_infos', 'label', 'debug','type', 'value'] as $sDeleteKey){ + if(isset($aElement[$sDeleteKey])){ + unset($aElement[$sDeleteKey]); + } + } + return $this->getHorizontalFormElement( + $this->_tag('textarea', $aElement, $value), + $sLabel, + $sFormid + ); + + } + } -- GitLab