search
HomeWeb Front-endLayui TutorialIntroduction to the use of layui framework form forms

Introduction to the use of layui framework form forms

Although I am familiar with layui, I have time today to take another look at the form module of layui.

1. Update rendering

layui does not have a two-way binding mechanism, but with a classic modular framework, you only need to execute the following method:

form.render(type, filter)

The first parameter: type

form.render(); //更新全部
form.render('select'); //刷新select选择框渲染
[select,checkbox,radio] //刷新[select选择框,checkbox复选框(含开关)][radio]渲染

The second parameter: filter [can be used for local updates] is the lay-filter of the element where class="layui-form" is located ="" value. You can use this parameter to complete partial updates to the form.

<div class="layui-form" lay-filter="test1"></div>
<div class="layui-form" lay-filter="test2"></div>
<script>
form.render(null, &#39;test1&#39;); //更新 lay-filter="test1" 所在容器内的全部表单状态
form.render(&#39;select&#39;, &#39;test2&#39;); //更新 lay-filter="test2" 所在容器内的全部 select 状态
</s

2. Default element attributes

<input type="text" lay-verify="email">
<input type="checkbox" checked lay-skin="switch" lay-filter="encrypt" title="是否加密">
<button lay-submit>提交</button>

Specific reference:

title: [Any value] Set the element name, used for checkbox, radio

lay-skin: [switch (switch style) primary (original style)] Set the element style, only valid for checkbox

lay-filter: time filter, similar to a selector, used for exact matching

lay-verify: [required (required), phone (mobile phone number), email (mailbox), url (website), number (number), date (date), identity (ID card)] used in forms Verification, supports multiple verification rules at the same time lay-verify="required|phone"

lay-verType: [tips (adsorption layer), alert (bullet box), msg (default)]: Set the exception prompt layer

lay-submit: Set the element that triggers submission.

For more layui knowledge, please pay attention to the layui usage tutorial column.

The above is the detailed content of Introduction to the use of layui framework form forms. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:博客园. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software