1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\Forms\Controls;
9:
10:
11: /**
12: * Submittable image button form control.
13: */
14: class ImageButton extends SubmitButton
15: {
16:
17: /**
18: * @param string URI of the image
19: * @param string alternate text for the image
20: */
21: public function __construct($src = null, $alt = null)
22: {
23: parent::__construct();
24: $this->control->type = 'image';
25: $this->control->src = $src;
26: $this->control->alt = $alt;
27: }
28:
29:
30: /**
31: * Loads HTTP data.
32: * @return void
33: */
34: public function loadHttpData()
35: {
36: parent::loadHttpData();
37: $this->value = $this->value
38: ? [(int) array_shift($this->value), (int) array_shift($this->value)]
39: : null;
40: }
41:
42:
43: /**
44: * Returns HTML name of control.
45: * @return string
46: */
47: public function getHtmlName()
48: {
49: return parent::getHtmlName() . '[]';
50: }
51: }
52: