<tap-pat-form>
Multi-field form page, such as editing a profile or creating an item. Pass groups to render grouped rows with the label on the left and the control on the right; no need to lay out tap-cell and controls by hand. For a single field use <tap-pat-editor>.
Done is enabled only after a value changes and all required fields are filled. Clicking it only emits change with the full value; going back or closing is up to the caller.
Example
Loading...
<tap-pat-form
style=${"width: 100%; height: 600px"}
.heading=${"Edit Profile"}
.value=${ { "name": "Mantou", "gender": "male", "notify": true, "count": 1 } }
.groups=${ [ { "items": [ {"name":"name","label":"Name","required":true}, { "name": "email", "label": "Email", "type": "email", "placeholder": "name@example.com" }, { "name": "gender", "label": "Gender", "type": "select", "options": [ {"label":"Male","value":"male"}, {"label":"Female","value":"female"} ] }, { "name": "birthday", "label": "Birthday", "type": "date" } ] }, { "heading": "Preferences", "footer": "Notifications are sent by email.", "items": [ { "name": "notify", "label": "Notifications", "type": "switch" }, { "name": "count", "label": "Copies", "type": "stepper", "min": 1, "max": 9 } ] }, { "items": [{"name":"bio","label":"Bio","type":"textarea"}] } ] }
@change=${(evt) => { console.log(evt.detail); evt.target.value = evt.detail }}></tap-pat-form>
API
多字段表单页,例如编辑资料、新建条目
点击完成后只发出 change,携带完整的值,关闭或返回由调用方处理
Extends GemElement
Instance Properties
| Property(Attribute) | Reactive | Type | Description |
|---|---|---|---|
heading(heading) |
Yes | string |
|
back(back) |
Yes | boolean |
Show the back button of the navbar, pops the closest stack |
groups |
Yes | FormGroup[] |
|
value |
Yes | FormValue |
|
change |
Emitter<FormValue> |
Other
| Type | Value |
|---|---|
| Event | change |
