protected $_enctype = 'application/x-www-form-urlencoded';
protected $_csrf = true;
protected $_title = '';
+ protected $_submitLabel = 'save';
+ protected $_submitIcon='la-save';
protected $crud;
public function __construct($action = '', $method = 'post')
$this->setAction($action);
$this->setMethod($method);
$this->crud = new CubistCrudPanel();
- $this->crud->model=new CubistMagicAbstractModel();
+ $this->crud->model = new CubistMagicAbstractModel();
parent::__construct();
}
*/
public function setMethod(string $method): void
{
- $this->_method = $method;
+ $this->_method = mb_strtolower($method);
+ }
+
+ public function getSafeMethod()
+ {
+ $safe = ['get', 'post'];
+ $m = $this->getMethod();
+ if (in_array($m, $safe)) {
+ return $m;
+ }
+ return 'post';
}
/**
return $field;
}
+ /**
+ * @return string
+ */
+ public function getSubmitLabel(): string
+ {
+ return $this->_submitLabel;
+ }
+
+ /**
+ * @param string $submitLabel
+ */
+ public function setSubmitLabel(string $submitLabel): void
+ {
+ $this->_submitLabel = $submitLabel;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSubmitIcon(): string
+ {
+ return $this->_submitIcon;
+ }
+
+ /**
+ * @param string $submitIcon
+ */
+ public function setSubmitIcon(string $submitIcon): void
+ {
+ $this->_submitIcon = $submitIcon;
+ }
+
public function getAutoFocusOnFirstField()
{
return true;
@endphp
<h2>{{$form->getTitle()}}</h2>
-
-@include('crud::form_content')
+<form action="{{$form->getAction()}}" enctype="{{$form->getEnctype()}}" method="{{$form->getSafeMethod()}}">
+ <input type="hidden" name="_method" value="{{$form->getMethod()}}">
+ @if($form->isCsrf())
+ @csrf
+ @endif
+ @include('crud::form_content')
+ <button type="submit" class="btn btn-success">
+ <span class="la {{$form->getSubmitIcon()}}" role="presentation" aria-hidden="true"></span>
+ <span data-value="save_and_back">{{$form->getSubmitLabel()}}</span>
+ </button>
+</form>