


yii2 drop-down box with search function yii2.0 video tutorial yii framework video tutorial yii official
Simple little function, but still quite fun to use. Share it so that more people can develop faster and program happily.
Author: Bailang Source: http://www.manks.top/yii2_dropdown_search.html The copyright of this article belongs to the author. Reprinting is welcome, but this statement must be retained without the author’s consent, and a link to the original text must be provided in an obvious position on the article page. Otherwise, we reserve the right to pursue legal liability.
If you haven’t used composer yet, you are out. Check out my tutorial sharing. Composer is simply a must-have and magical. Having said that, let’s quickly use composer to install it.
No rush, let’s take a look at the renderings first, otherwise you won’t be in the mood or have the desire to read on. The original article comes with pictures for reference.
What the hell are you not interested in? Just keep reading. Only then can you feel the benefits after reading it.
It feels very handsome. Of course, it is much more than that. It is also very high-end and the effect is amazing when used.
Okay, okay, hurry up and install it, otherwise the chat will be endless.
<code><span>composer require kartik-v/yii2-widget-<span>select2 <span>"<span>@dev" <span>#特别说明,因为这里安装的dev版本,也就是开发版本,不稳定版本,如果你的项目是git托管的,composer安装下来之后这里记得删掉 \vendor\kartik-v\yii2-widget-select2目录下的.git文件,不然你提交不上去的哦 </span></span></span></span></span></code>
Wait for about 5 minutes and it will be installed. Then we can start using it as below
//If your form is ActiveForm, please use
<code>use kartik\select2\Select2; //$data是键值对数组哦,key-value ,下面所声明的所有$data均为键值对数组,以该数组为例 $data = [<span>2 => <span>'widget', <span>3 => <span>'dropDownList', <span>4 => <span>'yii2']; echo $form->field($model, <span>'title')->widget(Select2::classname(), [ <span>'data' => $data, <span>'options' => [<span>'placeholder' => <span>'请选择 ...'], ]); </span></span></span></span></span></span></span></span></span></span></span></code>
//If your form Whether it is a non-ActiveForm, you can refer to the following
<code><span>use <span>kartik\<span>select2\<span>Select2; <span>echo Select2::widget([ <span>'name' => <span>'title', <span>'data' => $data, <span>'options' => [<span>'placeholder' => <span>'请选择...'] ]); </span></span></span></span></span></span></span></span></span></span></span></code>
When updating data generated by a non-ActiveFormr, it needs to be selected by default. It is easy to handle, just add the value
<code><span>use <span>kartik\<span>select2\<span>Select2; <span>echo Select2::widget([ <span>'name' => <span>'title', <span>'value' => <span>2, <span>'data' => $data, <span>'options' => [<span>'placeholder' => <span>'请选择...'] ]); <span>#但是如果你的表单是ActiveForm生成的,但是往往字段不是表字段怎么办呢?更好办啦,以上面的为例,你只需要指定$model->title = ['title1', 'title2'];即可 </span></span></span></span></span></span></span></span></span></span></span></span></span></span></code>
Continue reading
The above has introduced the yii2 drop-down box with search function, including the drop-down box and yii content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to implement a multi-select drop-down box in Vue. In Vue development, the drop-down box is one of the common form components. Normally, we use radio drop-down boxes to select an option. However, sometimes we need to implement a multi-select drop-down box so that users can select multiple options at the same time. In this article, we will introduce how to implement a multi-select drop-down box in Vue and provide specific code examples. 1. Use the ElementUI component library. ElementUI is a desktop component library based on Vue, which provides a rich UI.

With the continuous development of cloud computing technology, data backup has become something that every enterprise must do. In this context, it is particularly important to develop a highly available cloud backup system. The PHP framework Yii is a powerful framework that can help developers quickly build high-performance web applications. The following will introduce how to use the Yii framework to develop a highly available cloud backup system. Designing the database model In the Yii framework, the database model is a very important part. Because the data backup system requires a lot of tables and relationships

In the current information age, big data, artificial intelligence, cloud computing and other technologies have become the focus of major enterprises. Among these technologies, graphics card rendering technology, as a high-performance graphics processing technology, has received more and more attention. Graphics card rendering technology is widely used in game development, film and television special effects, engineering modeling and other fields. For developers, choosing a framework that suits their projects is a very important decision. Among current languages, PHP is a very dynamic language. Some excellent PHP frameworks such as Yii2, Ph

As the Internet continues to develop, the demand for web application development is also getting higher and higher. For developers, developing applications requires a stable, efficient, and powerful framework, which can improve development efficiency. Yii is a leading high-performance PHP framework that provides rich features and good performance. Yii3 is the next generation version of the Yii framework, which further optimizes performance and code quality based on Yii2. In this article, we will introduce how to use Yii3 framework to develop PHP applications.

The Yii framework is an open source PHP Web application framework that provides numerous tools and components to simplify the process of Web application development, of which data query is one of the important components. In the Yii framework, we can use SQL-like syntax to access the database to query and manipulate data efficiently. The query builder of the Yii framework mainly includes the following types: ActiveRecord query, QueryBuilder query, command query and original SQL query

As the demand for web applications continues to grow, developers have more and more choices in choosing development frameworks. Symfony and Yii2 are two popular PHP frameworks. They both have powerful functions and performance, but when faced with the need to develop large-scale web applications, which framework is more suitable? Next we will conduct a comparative analysis of Symphony and Yii2 to help you make a better choice. Basic Overview Symphony is an open source web application framework written in PHP and is built on

Yii framework: This article introduces Yii's method of converting objects into arrays or directly outputting them into json format. It has certain reference value and I hope it can help you.

If you're asking "What is Yii?" check out my previous tutorial: Introduction to the Yii Framework, which reviews the benefits of Yii and outlines what's new in Yii 2.0, released in October 2014. Hmm> In this Programming with Yii2 series, I will guide readers in using the Yii2PHP framework. In today's tutorial, I will share with you how to leverage Yii's console functionality to run cron jobs. In the past, I've used wget - a web-accessible URL - in a cron job to run my background tasks. This raises security concerns and has some performance issues. While I discussed some ways to mitigate the risk in our Security for Startup series, I had hoped to transition to console-driven commands
