bootstrap's helper improves

This commit is contained in:
Diego Najar 2018-10-31 17:56:32 +01:00
parent 47412a651d
commit 42ea1c2356
1 changed files with 42 additions and 23 deletions

View File

@ -102,33 +102,43 @@ EOF;
public static function formInputTextBlock($args) public static function formInputTextBlock($args)
{ {
$id = 'js'.$args['name']; $name = $args['name'];
$disabled = empty($args['disabled'])?'':'disabled';
$placeholder = isset($args['placeholder'])?$args['placeholder']:'';
$value = isset($args['value'])?$args['value']:'';
$id = 'js'.$name;
if (isset($args['id'])) { if (isset($args['id'])) {
$id = $args['id']; $id = $args['id'];
} }
$tip = '';
if (isset($args['tip'])) {
$tip = '<small class="form-text text-muted">'.$args['tip'].'</small>';
}
$label = '';
if (isset($args['label'])) {
$label = '<label class="mt-4 mb-2 pb-2 border-bottom text-uppercase w-100" for="'.$id.'">'.$args['label'].'</label>';
}
$class = 'form-control'; $class = 'form-control';
if (isset($args['class'])) { if (isset($args['class'])) {
$class = $class.' '.$args['class']; $class = $class.' '.$args['class'];
} }
$disabled = empty($args['disabled'])?'':'disabled'; $type = 'text';
if (isset($args['type'])) {
$html = '<div class="form-group m-0">'; $type = $args['type'];
if (isset($args['label'])) {
$html .= '<label class="mt-4 mb-2 pb-2 border-bottom text-uppercase w-100" for="'.$id.'">'.$args['label'].'</label>';
} }
$html .= '<input type="text" value="'.$args['value'].'" class="'.$class.'" id="'.$id.'" name="'.$args['name'].'" placeholder="'.$args['placeholder'].'" '.$disabled.'>'; return <<<EOF
<div class="form-group m-0">
if (isset($args['tip'])) { $label
$html .= '<small class="form-text text-muted">'.$args['tip'].'</small>'; <input type="text" value="$value" class="$class" id="$id" name="$name" placeholder="$placeholder" $disabled>
} $tip
</div>
$html .= '</div>'; EOF;
return $html;
} }
public static function formInputFile($args) public static function formInputFile($args)
@ -235,16 +245,25 @@ EOF;
public static function formInputText($args) public static function formInputText($args)
{ {
$label = isset($args['label'])?$args['label']:'';
$placeholder = isset($args['placeholder'])?$args['placeholder']:'';
$tip = isset($args['tip'])?$args['tip']:'&nbsp;';
$value = isset($args['value'])?$args['value']:'';
$name = $args['name']; $name = $args['name'];
$disabled = empty($args['disabled'])?'':'disabled';
$placeholder = isset($args['placeholder'])?$args['placeholder']:'';
$value = isset($args['value'])?$args['value']:'';
$id = 'js'.$name; $id = 'js'.$name;
if (isset($args['id'])) { if (isset($args['id'])) {
$id = $args['id']; $id = $args['id'];
} }
$disabled = empty($args['disabled'])?'':'disabled';
$tip = '';
if (isset($args['tip'])) {
$tip = '<small class="form-text text-muted">'.$args['tip'].'</small>';
}
$label = '';
if (isset($args['label'])) {
$label = '<label for="$id" class="col-sm-2 col-form-label">$label</label>';
}
$class = 'form-control'; $class = 'form-control';
if (isset($args['class'])) { if (isset($args['class'])) {
@ -258,10 +277,10 @@ EOF;
return <<<EOF return <<<EOF
<div class="form-group row"> <div class="form-group row">
<label for="$id" class="col-sm-2 col-form-label">$label</label> $label
<div class="col-sm-10"> <div class="col-sm-10">
<input class="$class" id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" $disabled> <input class="$class" id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" $disabled>
<small class="form-text text-muted">$tip</small> $tip
</div> </div>
</div> </div>
EOF; EOF;