Ip.php 648 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Dcat\Admin\Form\Field;
  3. use Dcat\Admin\Admin;
  4. class Ip extends Text
  5. {
  6. protected $rules = ['nullable', 'ip'];
  7. /**
  8. * @see https://github.com/RobinHerbots/Inputmask#options
  9. *
  10. * @var array
  11. */
  12. protected $options = [
  13. 'alias' => 'ip',
  14. ];
  15. public static function collectAssets()
  16. {
  17. Admin::collectComponentAssets('jquery.inputmask');
  18. }
  19. public function render()
  20. {
  21. $this->inputmask($this->options);
  22. $this->prepend('<i class="fa fa-laptop fa-fw"></i>')
  23. ->defaultAttribute('style', 'width: 200px');
  24. return parent::render();
  25. }
  26. }