From 0c5be26a2210f715d7862424714c66afc1dc4c9f Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 7 Jan 2021 15:26:57 +0100 Subject: [PATCH] wip #4174 @0.25 --- src/app/Magic/Form.php | 105 ++++++++++++++++++++++++ src/resources/views/form/form.blade.php | 8 ++ 2 files changed, 113 insertions(+) create mode 100644 src/resources/views/form/form.blade.php diff --git a/src/app/Magic/Form.php b/src/app/Magic/Form.php index e971936..7f744b2 100644 --- a/src/app/Magic/Form.php +++ b/src/app/Magic/Form.php @@ -4,10 +4,115 @@ namespace Cubist\Backpack\Magic; +use Illuminate\Support\Facades\Http; + class Form extends SubForm { + protected $_action = ''; + protected $_method = "post"; + protected $_enctype = 'application/x-www-form-urlencoded'; + protected $_csrf = true; + protected $_title = ''; + + + public function __construct($action = '', $method = 'post') + { + $this->setAction($action); + $this->setMethod($method); + parent::__construct(); + } + + /** + * @return string + */ + public function render() { + return view('form.form', ['form' => $this]); + } + + public function __toString() + { + return $this->render(); + } + + /** + * @return string + */ + public function getAction(): string + { + return $this->_action; + } + + /** + * @param string $action + */ + public function setAction(string $action): void + { + $this->_action = $action; + } + + /** + * @return string + */ + public function getEnctype(): string + { + return $this->_enctype; + } + /** + * @param string $enctype + */ + public function setEnctype(string $enctype): void + { + $this->_enctype = $enctype; + } + + /** + * @return string + */ + public function getMethod(): string + { + return $this->_method; + } + + /** + * @param string $method + */ + public function setMethod(string $method): void + { + $this->_method = $method; + } + + /** + * @return bool + */ + public function isCsrf(): bool + { + return $this->_csrf; + } + + /** + * @param bool $csrf + */ + public function setCsrf(bool $csrf): void + { + $this->_csrf = $csrf; + } + + /** + * @param string $title + */ + public function setTitle(string $title): void + { + $this->_title = $title; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->_title; } } diff --git a/src/resources/views/form/form.blade.php b/src/resources/views/form/form.blade.php new file mode 100644 index 0000000..ea23659 --- /dev/null +++ b/src/resources/views/form/form.blade.php @@ -0,0 +1,8 @@ +

{{$form->getTitle()}}

+
+
+ @if($form->isCsrf()) + @csrf + @endif +
+
-- 2.39.5