Wiki

Articles tagged with "model", sorted by viewsX
Displaying 1-10 of 28 result(s).

Reference: Model rules validation

Created 7 years ago by krillzipHow-tos7 comments – viewed 745,208 times – ( +128 / -1 ) – version 1.1
This is a reference to be used for Model rule validation and is compiled from the Yii documentation and code. The purpose is to have all the information gathered in one place instead of scattered. This reference is not an intro. See The Definitive Guide to Yii, Declaring Validation Rules for a tutorial.

Update two models with one view

Created 5 years ago by sensorarioTips11 comments – viewed 42,148 times – ( +10 / -3 ) – version 1.1
Suppose to have two models: Users and Emails. You do not want to store email in a Users model. And User can have 0 or many emails. This is the form generated to create a new user (just username).
tags: database, model, view, form

Single table inheritance

Created 6 years ago by samdarkHow-tos8 comments – viewed 37,989 times – ( +41 / -1 ) – version 1.1
Relational databases do not support inheritance so if we need to represent it, we have to somehow store meta info while keeping performance by minimizing JOINs. One way to solve this problem is using single table inheritance. All fields for the whole class tree are stored in a single table. Class name is stored in the type field of the same table.

Take more control of CGridview and model searching (related model or another controller)

Created 3 years ago by Kostas Apazidis (KonApaz)How-tos5 comments – viewed 32,093 times – ( +5 / -1 ) – version 1.1
Suppose you have an Application in Yii that manages hotels each one has many customers.

Search method of a model for filters when using dates - unixtimestamp in database

Created 6 years ago by MukkeTips1 comment – viewed 29,311 times – ( +10 / -1 ) – version 1.1
I ran into a problem and on irc we worked it out. Since there is a lack on information on filters in genral i thought i'd start sharing all my findings, might be usefull for other people.

"safe" and "unsafe" Model validators (massive assignments)

Created 4 years ago by Kostas Apazidis (KonApaz)How-tos4 comments – viewed 22,674 times – ( +4 / -7 ) – version 1.1
Ok, it is a little bit difficult to full understanding the unsafe validator.

Save or Update Multiple related model values in one Tabular input form

Created 3 years ago by Kostas Apazidis (KonApaz)Tutorials4 comments – viewed 22,369 times – ( +1 / -8 ) – version 1.1
In this wiki I will show you how to save/update a model with many related model For example: How to set a product to multiple categories only in one post form ?

Create Form With DynamicModel

Created 3 years ago by Misbahul D MunirTips4 comments – viewed 18,136 times – ( +2 / -1 ) – version 2.0
In yii2 we can create form without create FormModel. Here we go
tags: form, yii2, model

Generate a multi-lever array sub-category for a menu

Created 4 years ago by Kostas Apazidis (KonApaz)How-tos8 comments – viewed 18,030 times – ( +10 / -1 ) – version 1.1
Everyone have seen a multilayer menu in several CMS

Add model validator in Controller

Created 2 years ago by Kostas Apazidis (KonApaz)Tips4 comments – viewed 17,474 times – ( +1 / -2 ) – version 1.1
There are cases that model validators should be depended by controller/action and you couldn't manipulate on the model class or using scenarios in easy way