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