karbassi (owner)

Fork Of

Revisions

  • 49468f karbassi Sun Aug 17 15:49:51 -0700 2008
  • 75c1b3 fc Sun Aug 17 15:21:38 -0700 2008
  • 6d0f5a Sun Aug 17 15:05:42 -0700 2008
  • 4b96b9 Sun Aug 17 15:05:18 -0700 2008
  • 450251 Sun Aug 17 15:02:30 -0700 2008
gist: 5861 Download_button fork
public
Public Clone URL: git://gist.github.com/5861.git
Embed All Files: show embed
PHP #
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
example usage in subclassed form:
 
$this->addTableGroup(array(
// row 1
array(
$this->createElement('text', 'name1', array('label' => 'test1')),
$this->createElement('text', 'name2', array('label' => 'test1')),
),
// row 2
array(
$this->createElement('text', 'name1', array('label' => 'test1')),
$this->createElement('text', 'name2', array('label' => 'test1')),
),
));
*/
public function addTableGroup(array $rowsets, $return = false) {
 
$baseName = 'table-group-';
 
$form = new Zend_Form_SubForm();
$form->setIsArray(false);
$form->clearDecorators();
 
$body = new Zend_Form_SubForm();
$body->setIsArray(false);
 
foreach($rowsets as $id => $rowset){
 
if( isset($rowset[0][0]) && is_array($rowset[0])) {
//print '<pre>';print_r($rowset);exit;
$rowForm = $this->addTableGroup($rowset, true);
print_r($rowForm);
exit;
$body->addSubForm($rowForm, $baseName.$this->_uid++);
continue;
} else {
//print '<pre>'; print_r($rowset);exit;;
}
 
$rowForm = new Zend_Form_SubForm();
$rowForm->setIsArray(false);
$rowForm->addElements( $rowset );
$rowForm->setElementDecorators(array(
'ViewHelper',
'Errors',
array('HtmlTag', array('tag' => 'td')),
));
 
$body->addSubForm($rowForm, $baseName.$this->_uid++);
}
 
$form->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'table')),
));
 
$body->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'tbody')),
));
$body->setSubFormDecorators(array(
'FormElements',
array('HtmlTag', array('tag'=>'tr')),
));
 
$form->addSubForm($body, $baseName.$this->_uid++);
 
$this->addSubForm($form, $baseName.$this->_uid++);
}
PHP #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$this->addTableGroup(
array(
// Row 1
array(
array(
$this->createElement('text', 'name1-1', array('label' => 'test1-1')),
$this->createElement('text', 'name1-2', array('label' => 'test1-2')),
),
$this->createElement('text', 'name2', array('label' => 'test2')),
),
 
// Row 2
array(
$this->createElement('text', 'name3', array('label' => 'test3')),
$this->createElement('text', 'name4', array('label' => 'test4')),
)
)
);