WeChat Open Platform

Mini Programs Documentation


A form submitting <switch/>, <input/>, <checkbox/>, <slider/>, <radio/>, and <picker/> entered by users in components.

When the formType submit <button/> component in <form/> is tapped, the values in the form component will be submitted. The name needs to be added to the form component to serve as a key.

Attribute name Type Description
report-submit Boolean Whether to return formId used to send templated message
bindsubmit EventHandle Brings data in form to trigger a submit event, event.detail = {value : {'name': 'value'} , formId: ''}
bindreset EventHandle A reset event will be triggered when the form is reset

Sample code:

<form bindsubmit="formSubmit" bindreset="formReset">
  <view class="section section_gap">
    <view class="section__title">switch</view>
    <switch name="switch"/>
  <view class="section section_gap">
    <view class="section__title">slider</view>
    <slider name="slider" show-value ></slider>

  <view class="section">
    <view class="section__title">input</view>
    <input name="input" placeholder="please input here" />
  <view class="section section_gap">
    <view class="section__title">radio</view>
    <radio-group name="radio-group">
      <label><radio value="radio1"/>radio1</label>
      <label><radio value="radio2"/>radio2</label>
  <view class="section section_gap">
    <view class="section__title">checkbox</view>
    <checkbox-group name="checkbox">
      <label><checkbox value="checkbox1"/>checkbox1</label>
      <label><checkbox value="checkbox2"/>checkbox2</label>
  <view class="btn-area">
    <button formType="submit">Submit</button>
    <button formType="reset">Reset</button>
  formSubmit: function(e) {
    console.log('form experienced submit event, data brought is: ', e.detail.value)
  formReset: function() {
    console.log('form experienced reset event')