Display.php 458 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace Dcat\Admin\Form\Field;
  3. use Closure;
  4. use Dcat\Admin\Form\Field;
  5. class Display extends Field
  6. {
  7. protected $callback;
  8. public function with(Closure $callback)
  9. {
  10. $this->callback = $callback;
  11. }
  12. public function render()
  13. {
  14. if ($this->callback instanceof Closure) {
  15. $this->value = $this->callback->call($this->getFormModel(), $this->value());
  16. }
  17. return parent::render();
  18. }
  19. }