| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Frontend\Form\View\Theme\Fields; |
| 4 |
|
| 5 |
class ButtonField { |
| 6 |
public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) { |
| 7 |
$inputWrapper = new InputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value); |
| 8 |
$button = self::field($field, $rowID, $form_atomic_Cls_map, $formID); |
| 9 |
return $inputWrapper->wrapper($button, true, true); |
| 10 |
} |
| 11 |
|
| 12 |
private static function field($field, $rowID, $form_atomic_Cls_map, $formID, $error = null, $value = null) { |
| 13 |
$fieldHelpers = new FieldHelpers($field, $rowID, $form_atomic_Cls_map); |
| 14 |
// $helperTxt = self::helperTxt($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null); |
| 15 |
|
| 16 |
$btnPreIcn = $fieldHelpers->icon('btnPreIcn', 'btn-pre-i'); |
| 17 |
$btnSufIcn = $fieldHelpers->icon('btnSufIcn', 'btn-suf-i'); |
| 18 |
$disabled = $fieldHelpers->disabled(); |
| 19 |
// $name = $field->btnTyp === 'submit' ? 'name="bit-form-submit-btn"' : ''; |
| 20 |
$name = $fieldHelpers->name(); |
| 21 |
$spanner = '<span class="' . $fieldHelpers->getAtomicCls('spanner') . ' d-none"></span>'; |
| 22 |
$submitSpanner = 'submit' === $field->btnTyp ? $spanner : ''; |
| 23 |
|
| 24 |
return <<<BUTTONFIELD |
| 25 |
<div class="{$fieldHelpers->getAtomicCls('inp-fld-wrp')} {$fieldHelpers->getCustomClasses('inp-fld-wrp')}" |
| 26 |
{$fieldHelpers->getCustomAttributes('inp-fld-wrp')} |
| 27 |
> |
| 28 |
<button |
| 29 |
class="{$fieldHelpers->getAtomicCls('btn')} {$fieldHelpers->getCustomClasses('btn')}" |
| 30 |
{$fieldHelpers->getCustomAttributes('btn')} |
| 31 |
type="{$field->btnTyp}" |
| 32 |
{$name} |
| 33 |
{$disabled} |
| 34 |
> |
| 35 |
{$btnPreIcn} |
| 36 |
{$fieldHelpers->renderHTMR($field->txt)} |
| 37 |
{$btnSufIcn} |
| 38 |
{$submitSpanner} |
| 39 |
</button> |
| 40 |
</div> |
| 41 |
BUTTONFIELD; |
| 42 |
} |
| 43 |
|
| 44 |
private static function helperTxt($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) { |
| 45 |
$fieldHelpers = new FieldHelpers($field, $rowID, $form_atomic_Cls_map); |
| 46 |
$hlpPreIcn = $fieldHelpers->icon('hlpPreIcn', 'hlp-txt-pre-i'); |
| 47 |
$hlpSufIcn = $fieldHelpers->icon('hlpSufIcn', 'hlp-txt-suf-i'); |
| 48 |
$hlpTxt = isset($field->helperTxt) ? $fieldHelpers->renderHTMR($field->helperTxt) : ''; |
| 49 |
|
| 50 |
$helperTxt = <<<HELPERTXT |
| 51 |
<div |
| 52 |
class="{$fieldHelpers->getAtomicCls('hlp-txt')} {$fieldHelpers->getCustomClasses('hlp-txt')}" |
| 53 |
{$fieldHelpers->getCustomAttributes('hlp-txt')} |
| 54 |
> |
| 55 |
{$hlpPreIcn} |
| 56 |
{$hlpTxt} |
| 57 |
{$hlpSufIcn} |
| 58 |
</div> |
| 59 |
|
| 60 |
HELPERTXT; |
| 61 |
|
| 62 |
return property_exists($field, 'helperTxt') ? $helperTxt : ''; |
| 63 |
} |
| 64 |
} |
| 65 |
|