Wiki

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

Reference: Model rules validation

Created 5 years ago by krillzipHow-tos7 comments – viewed 536,347 times – ( +122 ) – 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.

Single table inheritance

Created 3 years ago by samdarkHow-tos7 comments – viewed 24,397 times – ( +39 ) – 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.

Model validation for field ranges using yii2-field-range extension

Created 7 months ago by Kartik VTips0 comments – viewed 3,065 times – ( +30 ) – version 2.0
The yii2-field-range extension enables you to easily setup ActiveField range fields with Bootstrap styling. You basically can setup two attributes joined together like a single field with combined validation error block.

How to store array/widget configuration to the database with config validation rules

Created 7 months ago by Kartik VTutorials0 comments – viewed 2,554 times – ( +30 / -4 ) – version 2.0
You may have scenarios, where you want to store a specific array configuration to the database. A classic example could be saving Yii widget configuration to the database and then retrieving it at runtime, with dynamic parameters set. This wiki discusses one of the approaches to do this. Let's consider you have something like the NavBar configuration below to store in the db:

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

Created about a year ago by KonApazHow-tos8 comments – viewed 11,658 times – ( +10 ) – version 1.1
Everyone have seen a multilayer menu in several CMS

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

Created 3 years ago by MukkeTips1 comment – viewed 23,404 times – ( +10 ) – 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.

Application-driven database with CDbMigration and an extended CActiveRecord

Created 3 years ago by Tudor IlisoiOthers0 comments – viewed 8,732 times – ( +8 ) – version 1.1
This is an incipient implementation of application-driven database with Yii.
tags: database, model

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

Created about a year ago by KonApazHow-tos5 comments – viewed 19,127 times – ( +5 ) – version 1.1
Suppose you have an Application in Yii that manages hotels each one has many customers.

Update CGridview row separately using ajax request

Created 8 months ago by KonApazHow-tos6 comments – viewed 6,567 times – ( +5 ) – version 1.1
There are cases you want to update a record on CGridview directly

Update two models with one view

Created 3 years ago by sensorarioTips11 comments – viewed 32,818 times – ( +10 / -2 ) – 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