v1.php 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'formgroup' . DS . 'v1.php';
  4. class formRow extends wg
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defineProps = array(
  10. 'width?: string',
  11. 'items?: array',
  12. 'hidden?: boolean'
  13. );
  14. public function onBuildItem($item)
  15. {
  16. if(!($item instanceof item))
  17. {
  18. if($item instanceof node) return $item;
  19. $item = item(set($item));
  20. }
  21. return new formGroup(inherit($item));
  22. }
  23. protected function build()
  24. {
  25. list($width, $items, $hidden) = $this->prop(['width', 'items', 'hidden']);
  26. return div
  27. (
  28. set::className('form-row', empty($width) ? null : 'grow-0', $hidden ? 'hidden' : ''),
  29. zui::width($width),
  30. is_array($items) ? array_map(array($this, 'onBuildItem'), $items) : null,
  31. set($this->getRestProps()),
  32. $this->children()
  33. );
  34. }
  35. }