1: <?php
2:
3: class InputsOnSubmit {
4:
5: /**
6: *
7: * @var ExtendedFormHelper
8: */
9: private $parent;
10:
11: /**
12: *
13: * @var array
14: */
15: private $inputs = array();
16:
17: public function __construct(ExtendedFormHelper $parent) {
18: $this->parent = $parent;
19: }
20:
21: public function addInput($type, $visibleInputId, $hiddenInputId) {
22: $this->inputs[] = compact('type','visibleInputId','hiddenInputId');
23: }
24:
25: public function outputJavascript() {
26: $b = '';
27: foreach($this->inputs as $input) {
28: $b .= $this->_inputOnSubmitEvent($input);
29: }
30: return $b;
31: }
32:
33: private function _inputOnSubmitEvent($input) {
34: switch ($input['type']) {
35: case 'text':
36: return $this->_maskedTextOnSubmit($input);
37:
38: case 'date':
39: case 'time':
40: case 'datetime':
41: return DateTimeInput::onSubmit($input);
42:
43: default:
44: throw new Exception("Type not mapped: \"{$input['type']}\".");
45: }
46: }
47:
48: private function _maskedTextOnSubmit($input) {
49: return <<<EOT
50: {
51: var text = \$('#{$input['visibleInputId']}').val();
52: \$('#{$input['hiddenInputId']}').inputmask('setvalue',text);
53: }
54: EOT;
55: }
56: }
57:
58: ?>
59: