source: trunk/class/Form.php

Last change on this file was 18, checked in by maron, 12 years ago

kostra webu

File size: 1.1 KB
Line 
1<?php
2
3// Formular class
4// Date: 2012-06-19
5
6class Form
7{
8
9 protected $action = '';
10 protected $method = 'post';
11 protected $inputs = array();
12 protected $title = '';
13
14 function __construct($inputs,$title,$action = '?',$method = 'post')
15 {
16 $this->action = $action;
17 $this->title = $title;
18 $this->method = $method;
19 $this->inputs = $inputs;
20 }
21
22 function GetText() {
23 $return = '';
24 if ($this->title != '') $return .= '<strong>'.$this->title.'</strong>';
25 $return .= '
26 <form action="'.$this->action.'" method="'.$this->method.'">
27 <table>';
28
29 foreach($this->inputs as $input)
30 {
31 $return .= '<tr>';
32
33 if (isset($input['description'])) $return .= '<td>'.$input['description'].'</td>';
34 else $return .= '<td></td>';
35
36 $return .= '<td><input ';
37
38 if (isset($input['type'])) $return .= 'type="'.$input['type'].'" ';
39 if (isset($input['name'])) $return .= 'name="'.$input['name'].'" ';
40 if (isset($input['value'])) $return .= 'value="'.$input['value'].'" ';
41
42 $return .= '/></td></tr>';
43 }
44
45 $return .= '</table>
46 </form>';
47 return $return;
48 }
49
50 function Show()
51 {
52
53 echo $this->GetText();
54 }
55
56}
57?>
Note: See TracBrowser for help on using the repository browser.