- Added a new form() method to ease form handling
This commit is contained in:
1 parent
94e42747a4
commit
9c8a28d294
2 files changed
+80
-6
No files matched your search
+8
-6
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Picea\Ui\Form;
|
||||
|
||||
use Picea\Ui\Common\UiElement;
|
||||
use Picea\Extension\Extension;
|
||||
use Picea\Extension\ExtensionTrait;
|
||||
use Picea\Ui\Common\UiElement,
|
||||
Picea\Extension\Extension,
|
||||
Picea\Extension\ExtensionTrait;
|
||||
|
||||
class UiForm extends UiElement implements Extension {
|
||||
use ExtensionTrait;
|
||||
@@ -23,7 +23,7 @@ class UiForm extends UiElement implements Extension {
|
||||
{
|
||||
switch($token) {
|
||||
case 'ui.endform':
|
||||
return "</form>";
|
||||
return ( new UiHidden() )->attributes([ 'name' =>"picea-csrf-protection", 'value' => "abcdefg" ])->render() . "</form>";
|
||||
|
||||
case "ui.form.get":
|
||||
$method = "get";
|
||||
@@ -50,10 +50,12 @@ class UiForm extends UiElement implements Extension {
|
||||
return "<?php echo ( new \\" . static::class . "() )->buildHtml('$method', $arguments) ?>";
|
||||
}
|
||||
|
||||
|
||||
public function buildHtml(string $method, string $action, array $attributes = []) : string
|
||||
{
|
||||
$this->option('tag-type', 'single');
|
||||
$this->attributes([ 'action' => $action ] + $attributes);
|
||||
$this->attributes([ 'method' => $method, 'action' => $action ] + $attributes);
|
||||
|
||||
return $this->render() . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user