Skip to content
Snippets Groups Projects
Commit d9b8c394 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

WIP getInput

parent 953720ea
No related branches found
No related tags found
No related merge requests found
...@@ -400,18 +400,71 @@ class renderadminlte { ...@@ -400,18 +400,71 @@ class renderadminlte {
'linktext'=>['group'=>'content', 'description'=>'used if a url was given: linked text', 'example_value'=>'More info'] 'linktext'=>['group'=>'content', 'description'=>'used if a url was given: linked text', 'example_value'=>'More info']
] ]
], ],
// ------------------------------------------------------------
'input'=>[
'label'=>'Form: input',
'description'=>'Input form fiels',
'method'=>'getInput',
'params'=>[
'label' => [
'group'=>'styling',
'description'=>'label for the input field',
'example_value'=>'Enter your firstname'
],
'type'=>['select'=> [
'description'=>'type or input field',
'group'=>'styling',
'values'=>[
'text'=>'text',
'password'=>'password',
'email'=>'email',
'hidden'=>'hidden',
]
],
'example_value'=>'text'
],
'class' => [
'group'=>'styling',
'description'=>'optional: css classes',
'example_value'=>'myclass'
],
'prepend' => [
'group'=>'styling',
'description'=>'optional: content on input start',
'example_value'=>'+'
],
'append' => [
'group'=>'styling',
'description'=>'optional: content on input end',
'example_value'=>':-)'
],
'name' => [
'group'=>'content',
'description'=>'name attribute',
'example_value'=>'firstname'
],
'value' => [
'group'=>'content',
'description'=>'Value',
'example_value'=>'Jack'
],
]
],
]; ];
} }
/** /**
* helper function: a shortcut for $this->_oHtml->getTag * helper function: a shortcut for $this->_oHtml->getTag
* @param string $sTag name of html tag * @param string $sTag name of html tag
* @param array $aAttributes array of its attributes * @param array $aAttributes array of its attributes
* @param string $sContent content between opening and closing tag
* @param bool $bClosetag flag: write a closing tag or not? default: true
*/ */
protected function _tag($sTag, $aAttributes, $sContent=false){ protected function _tag($sTag, $aAttributes, $sContent=false, $bClosetag=true){
if ($sContent){ if ($sContent){
$aAttributes['label']=(isset($aAttributes['label']) ? $aAttributes['label'] : '') . $sContent; $aAttributes['label']=(isset($aAttributes['label']) ? $aAttributes['label'] : '') . $sContent;
} }
return $this->_oHtml->getTag($sTag, $aAttributes); return $this->_oHtml->getTag($sTag, $aAttributes, $bClosetag);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
...@@ -1111,45 +1164,61 @@ class renderadminlte { ...@@ -1111,45 +1164,61 @@ class renderadminlte {
} }
/* /**
* return a text input field:
<div class="info-box"> * https://adminlte.io/themes/v3/pages/forms/general.html
<span class="info-box-icon bg-info"><i class="far fa-bookmark"></i></span> *
<div class="info-box-content"> * @param type $aOptions hash with keys for all options
<span class="info-box-text">Bookmarks</span> * styling:
<span class="info-box-number">41,410</span> * - type - field type: text, email, password, hidden
<div class="progress"> * content
<div class="progress-bar bg-info" style="width: 70%"></div> * - label - label tag
</div> * - name - name attribute for sending form
<span class="progress-description"> * - value - value in
70% Increase in 30 Days * @return string
</span>
</div>
</div>
<div class="info-box bg-success">
<span class="info-box-icon"><i class="far fa-thumbs-up"></i></span>
<div class="info-box-content">
<span class="info-box-text">Likes</span>
<span class="info-box-number">41,410</span>
<div class="progress">
<div class="progress-bar" style="width: 70%"></div>
</div>
<span class="progress-description">
70% Increase in 30 Days
</span>
</div>
</div>
*/ */
public function GetInput($aOptions){
$aOptions=$this->_ensureOptions('input', $aOptions);
$aElement=$aOptions;
$aElement['class']=''
. $this->_addClassValue($aOptions['class'], '')
;
$sFormid=(isset($aOptions['id'])
? $aOptions['id']
: (isset($aOptions['name']) ? $aOptions['name'] : 'field' ).'-'.md5(microtime(true))
);
$sLabel='';
$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';
$sPrepend=$this->_tag('div',[ 'class'=>'input-group-prepend'],
$this->_tag('span', ['class'=>'input-group-text'] , $aOptions['prepend'])
);
}
if(isset($aOptions['append']) && $aOptions['append']){
$sWrapperclass='input-group';
$sAppend=$this->_tag('div',[ 'class'=>'input-group-append'],
$this->_tag('span', ['class'=>'input-group-text'] , $aOptions['append'])
);
}
return $this->_tag('div', ['class'=>$sWrapperclass],
$sLabel
.$sPrepend
.$this->_tag('input', $aElement, '', false)
.$sAppend
);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment