]> _ Git - cubist_cms-back.git/commitdiff
wip #4174 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 7 Jan 2021 14:26:57 +0000 (15:26 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 7 Jan 2021 14:26:57 +0000 (15:26 +0100)
src/app/Magic/Form.php
src/resources/views/form/form.blade.php [new file with mode: 0644]

index e971936c3a1030ef8f8d04cb7b1338429137b81e..7f744b2e8895981d6aca1c540d2e70c0620b9ddb 100644 (file)
 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 (file)
index 0000000..ea23659
--- /dev/null
@@ -0,0 +1,8 @@
+<h2>{{$form->getTitle()}}</h2>
+<div class="card">
+    <form action="{{$form->getAction()}}" method="{{$form->getMethod()}}" enctype="{{$form->getEnctype()}}">
+        @if($form->isCsrf())
+            @csrf
+        @endif
+    </form>
+</div>