Wiki articles in category Tips tagged with "model"

Showing 1-10 of 10 items.

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

Created 13 years ago by Mukke, updated 12 years ago by jwerner.

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.

10 0
11 followers
Viewed: 37 192 times
Version: 1.1
Category: Tips

Managing constants easily

Created 12 years ago by briiC.lv, updated 12 years ago by briiC.lv.

/*

    Get class constants by token.
    If you set constants with same prefix, like:
	MY_STATUS_1
	MY_STATUS_2
	MY_STATUS_3
4 0
7 followers
Viewed: 30 573 times
Version: 1.1
Category: Tips

Update two models with one view

Created 12 years ago by sensorario, updated 11 years ago by SebK.

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).

9 3
13 followers
Viewed: 55 371 times
Version: 1.1
Category: Tips

Inline views, write less

Created 10 years ago by Firebreaker, updated 10 years ago by Firebreaker.

Sometimes writing views like

3 0
3 followers
Viewed: 11 520 times
Version: Unknown (update)
Category: Tips

How to preload dropdowns in CForm

Created 10 years ago by transistor, updated 10 years ago by transistor.

So you want to use CForm (form builder), but need to preload dropdowns in a form? It's simpler than it seems.
You got your CFormModel, CForm and the actual Form, right?
Let's say you have the typical State -> City dependent dropdowns, so you would want to load the from with the State and City selected.

1 0
2 followers
Viewed: 11 847 times
Version: Unknown (update)
Category: Tips

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

Created 9 years ago by Kartik V, updated 9 years ago by Kartik V.

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.

0 0
37 followers
Viewed: 27 588 times
Version: 2.0
Category: Tips

Expert's model generation with Gii

Created 9 years ago by le_top, updated 9 years ago by le_top.

Efficient coding with Yii implies efficient use of the code generator. This article shares the personalised Gii templates that were built starting from the standard templates proposed by AweGen.

1 0
2 followers
Viewed: 16 898 times
Version: 1.1
Category: Tips

Create Form With DynamicModel

Created 9 years ago by Misbahul D Munir, updated 9 years ago by Misbahul D Munir.

In yii2 we can create form without create FormModel. Here we go

4 0
8 followers
Viewed: 47 054 times
Version: 2.0
Category: Tips
Tags: form, model, yii2

Add model validator in Controller

Created 9 years ago by Kostas Apazidis (KonApaz), updated 9 years ago by Kostas Apazidis (KonApaz).

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

1 1
3 followers
Viewed: 30 791 times
Version: 1.1
Category: Tips

A universal model attribute for its synthetic representation

Created 7 years ago by Alexandre Rodichevski, updated 7 years ago by Alexandre Rodichevski.

It is convenient to use the same identification attribute, say info, in all of the active records of your application. It should be a virtual read-only attribute defined by a getter method, its label being the model name.

0 0
3 followers
Viewed: 14 551 times
Version: 2.0
Category: Tips