Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the specified value according to the condition of yii2

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to set the specified value according to the conditions of yii2". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to set the specified value according to the conditions of yii2"!

In the _ form.php file automatically generated by gii, we can judge whether it is being added or updated according to the value returned by the code $model- > isNewRecord. In the form.php file, we can also assign a default value to the field input box according to its attribute value.

The connect field is a multi-check box field, and the data passed from the foreground to the background is in array format by default. The corresponding field is handled by the tostring method, assigning its value to the static variable $connect, and then formatting the array into a string in beforeSave, which is returned and stored in the database.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report