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