FormBuilder.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\services;
  12. use FormBuilder\Factory\Iview as Form;
  13. use FormBuilder\UI\Iview\Components\InputNumber;
  14. /**
  15. * Form Builder
  16. * Class FormBuilder
  17. * @package crmeb\services
  18. */
  19. class FormBuilder extends Form
  20. {
  21. public static function setOptions($call)
  22. {
  23. if (is_array($call)) {
  24. return $call;
  25. } else {
  26. return $call();
  27. }
  28. }
  29. public static function number($field,$title,$value = null){
  30. $number = new InputNumber($field, $title, $value);
  31. if (!$number->getProp('max')) {
  32. if ($field == 'sort') {
  33. $number->max(99999);
  34. if (!$number->getProp('min')) {
  35. $number->min(0);
  36. }
  37. } else {
  38. $number->max(9999999999);
  39. }
  40. }
  41. return $number;
  42. }
  43. }