Button.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Form button element
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Framework\Data\Form\Element;
  12. use Magento\Framework\Escaper;
  13. class Button extends AbstractElement
  14. {
  15. /**
  16. * Additional html attributes
  17. *
  18. * @var string[]
  19. */
  20. protected $_htmlAttributes = ['data-mage-init'];
  21. /**
  22. * @param Factory $factoryElement
  23. * @param CollectionFactory $factoryCollection
  24. * @param Escaper $escaper
  25. * @param array $data
  26. */
  27. public function __construct(
  28. Factory $factoryElement,
  29. CollectionFactory $factoryCollection,
  30. Escaper $escaper,
  31. $data = []
  32. ) {
  33. parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
  34. $this->setType('button');
  35. $this->setExtType('textfield');
  36. }
  37. /**
  38. * Html attributes
  39. *
  40. * @return string[]
  41. */
  42. public function getHtmlAttributes()
  43. {
  44. $attributes = parent::getHtmlAttributes();
  45. return array_merge($attributes, $this->_htmlAttributes);
  46. }
  47. }