picea-ui/docs/10-ui-form.md

34 lines
1.0 KiB
Markdown
Raw Permalink Normal View History

2023-02-02 16:43:15 +00:00
# `ui:form` / `ui:form.get` / `ui:form.post` (string $method = "get", string $name = "", string $action = "", array $attributes = [])
2023-02-02 16:43:15 +00:00
A version exists also for unsupported methods (as of HTML5) on forms `ui:form.put` / `ui:form.patch` / `ui:form.delete`, which
could find a use within a Javascript environment.
The following attributes are assigned by this extension :
- `'class' => "ui-form"`
- `'enctype' => "multipart/form-data"`
- `'method' => "get|post|put|patch|delete"`
and will typically be rendered such as :
```html
<form class="ui-form" enctype="multipart/form-data" action="$action" method="$method">
<input class="ui-hidden" type="hidden" name="picea-ui-form[$name]" value="{ random md5 hash }">
</form>
```
### Additional options
You can now remove the enctype attribute `no-enctype` or the CSRF token `no-csrf` using those option
on the form tag :
```html
{% ui:form.post.no-enctype.no-csrf "my.form" %} {% endform %}
```
and would render as such :
```html
<form class="ui-form" action="$action" method="$method">
</form>
```