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