1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Nette\Forms\Controls;
13:
14: use Nette;
15:
16:
17: 18: 19: 20: 21:
22: class ImageButton extends SubmitButton
23: {
24:
25: 26: 27: 28:
29: public function __construct($src = NULL, $alt = NULL)
30: {
31: parent::__construct();
32: $this->control->type = 'image';
33: $this->control->src = $src;
34: $this->control->alt = $alt;
35: }
36:
37:
38: 39: 40: 41:
42: public function getHtmlName()
43: {
44: $name = parent::getHtmlName();
45: return strpos($name, '[') === FALSE ? $name : $name . '[]';
46: }
47:
48:
49: 50: 51: 52:
53: public function loadHttpData()
54: {
55: $path = $this->getHtmlName();
56: $path = explode('[', strtr(str_replace(']', '', strpos($path, '[') === FALSE ? $path . '.x' : substr($path, 0, -2)), '.', '_'));
57: $this->setValue(Nette\Utils\Arrays::get($this->getForm()->getHttpData(), $path, NULL));
58: }
59:
60: }
61: