-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMultiform.php
More file actions
45 lines (37 loc) · 1.04 KB
/
Multiform.php
File metadata and controls
45 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
class Evil_Multiform extends Zend_Form
{
private static $_instanceCounter = 0;
public static $_idParam = 'formid';
public function __construct($options = null)
{
parent:: __construct($options);
$this->setMethod('GET');
self::$_instanceCounter++;
$idEl = new Zend_Form_Element_Hidden(self::$_idParam);
$idEl->setRequired(false);
$idEl->setValue($this->_getFormid());
$this->setAttrib('id', $this->_getFormid());
$this->addElement($idEl);
}
protected function _getFormid()
{
return sprintf('form-%s-instance-%d', $this->_getFormType(), self::$_instanceCounter);
}
protected function _getFormType()
{
return get_class($this);
}
public function isValid($data)
{
if(isset($data[self::$_idParam]) && $data[self::$_idParam] == $this->_getFormid() )
{
//unset($data[self::$_idParam]);
return parent::isValid($data);
} else
{
//ничо
return false;
}
}
}