Sometimes writing views like
Sometimes writing views like
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.
Suppose we want to set a category to product (or an item in general term), Also suppose categories has sub-categories (multi-level)
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.
This is an incipient implementation of application-driven database with Yii.
One of the common tasks the web application might be required to perform, especially the app using some kind of a CMS, is to save the history of data changes. Your client for sure will want the answer to this simple question - If I mess this up or delete by accident can we bring it back? Well, DB backup is one thing and quick recovery is another - let's talk about latter one.
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.
CGridview displays existent rows of the table (using DataProvider)
There are cases that you want to validate the file format, size, extension etc but how to do that without submit the form ?
Suppose you have Products,Categories and each product belongs in many categories
This is a reference about model validators and user roles. In many cases we want model validators to applied only for some privileged users or not
I just chased my tail around for a bit today. I got lost with setting the status of all inputs, and banging my head on why the "validate" function just wasn't working.
Note the tag {{homeUrl}}
will be dynamically replaced at runtime.
There are cases you want to update a record on CGridview directly
Everyone have seen a multilayer menu in several CMS
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.
/*
Get class constants by token.
If you set constants with same prefix, like:
MY_STATUS_1
MY_STATUS_2
MY_STATUS_3
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
This tutorial shows you how to safely remove records between relationships.
Ok, it is a little bit difficult to full understanding the unsafe validator.