BxTemplFormView.php 992 B

123456789101112131415161718192021222324252627282930
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaTemplate UNA Template Classes
  7. * @{
  8. */
  9. class BxTemplFormView extends BxBaseFormView
  10. {
  11. public function __construct($aInfo, $oTemplate = false)
  12. {
  13. parent::__construct($aInfo, $oTemplate);
  14. }
  15. public function genInputSwitcher(&$aInput)
  16. {
  17. $aCheckbox = array_merge($aInput, ['type' => 'checkbox']);
  18. $bChecked = isset($aInput['checked']) && $aInput['checked'];
  19. return $this->oTemplate->parseHtmlByName('form_field_switcher.html', [
  20. 'class' => $bChecked ? 'on' : 'off',
  21. 'checked' => $bChecked ? 'true' : 'false', // the button's initial aria-checked; jquery.webForms.js keeps it in step
  22. 'checkbox' => $this->genInputStandard($aCheckbox),
  23. 'bx_if:show_label' => $this->genInputSwitcherLabel($aInput)
  24. ]);
  25. }
  26. }
  27. /** @} */