psf
 All Classes Functions Variables
form.php
1 <?php
2 
3 //Part of simple php framework (spf)
4 
5 //This program is free software: you can redistribute it and/or modify
6 //it under the terms of the GNU General Public License as published by
7 //the Free Software Foundation, either version 3 of the License, or
8 //(at your option) any later version.
9 
10 //This program is distributed in the hope that it will be useful,
11 //but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 //GNU General Public License for more details.
14 
15 //Copyright Petr Bena 2015
16 
17 if (!defined("PSF_ENTRY_POINT"))
18  die("Not a valid psf entry point");
19 
20 require_once (dirname(__FILE__) . "/../css/inline.php");
21 require_once (dirname(__FILE__) . "/container.php");
22 
23 abstract class FormMethod
24 {
25  const Get = "get";
26  const Post = "post";
27 }
28 
29 class Form extends HtmlContainer
30 {
31  public $Action = NULL;
32  public $Method = FormMethod::Get;
33 
34  public function __construct($_action = NULL, $_parent = NULL)
35  {
36  $this->Action = $_action;
37  parent::__construct($_parent);
38  }
39 
40  public function ToHtml()
41  {
42  if ($this->Action === NULL)
43  {
44  $bx = "<form>\n";
45  } else
46  {
47  $bx = '<form action="' . $this->Action . '" method="' . $this->Method . '">' . "\n";
48  }
49  $bx .= parent::ToHtml();
50  $bx .= "</form>";
51  return $bx;
52  }
53 }