php-censor/src/Form.php

70 lines
1 KiB
PHP
Raw Normal View History

2016-04-12 19:31:39 +02:00
<?php
2018-03-04 11:50:08 +01:00
namespace PHPCensor;
2016-04-21 19:05:32 +02:00
2018-03-04 11:50:08 +01:00
use PHPCensor\Form\FieldSet;
2016-04-12 19:31:39 +02:00
class Form extends FieldSet
{
2017-11-05 15:48:36 +01:00
/**
* @var string
*/
2018-01-18 15:51:33 +01:00
protected $action = '';
2017-11-05 15:48:36 +01:00
/**
* @var string
*/
2018-01-18 15:51:33 +01:00
protected $method = 'POST';
2016-04-21 19:05:32 +02:00
2017-11-05 15:48:36 +01:00
/**
* @return string
*/
2016-04-21 19:05:32 +02:00
public function getAction()
{
2018-01-18 15:51:33 +01:00
return $this->action;
2016-04-21 19:05:32 +02:00
}
2017-11-05 15:48:36 +01:00
/**
* @param string $action
*/
2016-04-21 19:05:32 +02:00
public function setAction($action)
{
2018-01-18 15:51:33 +01:00
$this->action = $action;
2016-04-21 19:05:32 +02:00
}
2017-11-05 15:48:36 +01:00
/**
* @return string
*/
2016-04-21 19:05:32 +02:00
public function getMethod()
{
2018-01-18 15:51:33 +01:00
return $this->method;
2016-04-21 19:05:32 +02:00
}
2017-11-05 15:48:36 +01:00
/**
* @param string $method
*/
2016-04-21 19:05:32 +02:00
public function setMethod($method)
{
2018-01-18 15:51:33 +01:00
$this->method = $method;
2016-04-21 19:05:32 +02:00
}
2017-11-05 15:48:36 +01:00
/**
* @param View $view
*/
2017-01-13 16:35:41 +01:00
protected function onPreRender(View &$view)
2016-04-21 19:05:32 +02:00
{
$view->action = $this->getAction();
$view->method = $this->getMethod();
2017-01-13 16:35:41 +01:00
parent::onPreRender($view);
2016-04-21 19:05:32 +02:00
}
2017-11-05 15:48:36 +01:00
/**
* @return string
*/
2016-04-21 19:05:32 +02:00
public function __toString()
{
return $this->render();
}
}