v1.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace zin;
  3. class formItemDropdown extends wg
  4. {
  5. /**
  6. * @var mixed[]
  7. */
  8. protected static $defineProps = array(
  9. 'items?:array',
  10. 'value?:array',
  11. 'method?: string',
  12. 'url?: string',
  13. 'actions?: array',
  14. 'target?: string'
  15. );
  16. public static function getPageCSS()
  17. {
  18. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  19. }
  20. private function buildFormPanel()
  21. {
  22. global $lang;
  23. $props = $this->prop(['method', 'url', 'actions', 'target']);
  24. return form
  25. (
  26. p
  27. (
  28. $lang->customField,
  29. setClass('text-base font-bold mb-1')
  30. ),
  31. set($props),
  32. setID('custom'),
  33. setClass('dropdown-menu p-5 bg-white'),
  34. formGroup
  35. (
  36. setClass('not-hide-menu w-20 mb-1'),
  37. checkList
  38. (
  39. set
  40. (
  41. array(
  42. 'class' => 'h-full flex-wrap gap-y-5',
  43. 'primary' => true,
  44. 'inline' => true,
  45. 'value' => $this->prop('value'),
  46. 'items' => $this->prop('items')
  47. )
  48. )
  49. )
  50. ),
  51. set::actions
  52. (
  53. array(
  54. array('text' => $lang->save, 'class' => 'primary'),
  55. array('text' => $lang->cancel),
  56. array('text' => $lang->restore, 'class' => 'ghost text-primary', 'btnType' => 'reset')
  57. )
  58. )
  59. );
  60. }
  61. protected function build()
  62. {
  63. return div
  64. (
  65. setClass('form-item-dropdown'),
  66. btn
  67. (
  68. set
  69. (
  70. array(
  71. 'class' => 'ghost',
  72. 'icon' => 'cog',
  73. 'data-target' => 'custom',
  74. 'data-toggle' => 'dropdown'
  75. )
  76. )
  77. ),
  78. $this->buildFormPanel()
  79. );
  80. }
  81. }