Wiki

Articles tagged with "behavior", sorted by ratingX
Displaying 1-9 of 9 result(s).

Save and Display Date/Time Fields in different formats in Yii2

Created 5 months ago by Kartik VHow-tos10 comments – viewed 5,936 times – ( +27 ) – version 2.0
You would find having such a need in most Yii Projects. Your database needs a specific format to store date fields, while you may want to display it in different formats to the users on forms and other views.

How to use an application behavior to maintain runtime configuration

Created 3 years ago by zaccariaHow-tos3 comments – viewed 24,421 times – ( +27 ) – version 1.1
In this tutorial will be explained a method to manage some configuration runtime. This excellent tutorial follows a similar approach, but requires to write a masterclass which all controllers are supposed to extend, following this wiki you can achieve the same by only editing the configuration.

Manage (Target) Language in Multilingual Applications + A Language Selector Widget (i18n)

Created 2 years ago by c@cbaTutorials10 comments – viewed 27,217 times – ( +15 ) – version 1.1
In case of a multilingual application, one might consider it a reasonable approach to store the preferred language of the user in a session variable, and after that, every time a page is requested, to check this session variable and render the page in the indicated language. This tutorial shows a Yii-way of doing this. We implement an event handler for the onBeginRequest event; as the name of the event suggests, this event handler will be called at the beginning of each request, so its a good place to check whether a language is provided (via post, session or cookie) and set the application language accordingly. We also implement a simple Language-Selector Widget, which can render the language options as ajax-links or as a drop-down list.

Fixing extensions without modifying their code

Created about a year ago by schmunkTips3 comments – viewed 5,882 times – ( +6 ) – version 1.1
If you're working a lot with extensions you often stumble upon problems, when you want to include them into your custom web application, like hardcoded or absolute path aliases or classes extended from core application components, which implement addiditonal features.

CGridView: Adding behaviors from configuration, and template items from behaviors to CGridView

Created about a year ago by le_topTips0 comments – viewed 6,618 times – ( +5 ) – version 1.1
Changing the way a CGridView is rendered from the configuration file, or through behaviors specified at the moment it is used, is handy to extend a CGridView without creating tons of different classes for it. I am surprised that this is not in the default implementation, so I made my default CGridView implementation.

How to implement an event and attach it in a behavior

Created about a year ago by seb7How-tos0 comments – viewed 10,411 times – ( +5 ) – version 1.1
This page explains how to implement an event and catch that event in a behavior.
tags: event, behavior

Rendering a view file in a console application

Created 2 years ago by TompiHow-tos1 comment – viewed 7,895 times – ( +3 / -2 ) – version 1.1
When someone want to send formatted HTML mails from a console application she/he will probably come across the problem of rendering view files.

Auto-update denormalized attributes with MongoDb and Yii2

Created 7 months ago by edoardo849Tips0 comments – viewed 3,387 times – ( +1 ) – version 2.0
You have different collections in MongoDb with de-normalized attributes. As you may know, due to its not-join nature, MongoDb tends to encourage repetition of the same value in different collections (de-normalization). In this MongoDb is opposed to a more SQL-like approach where you usually reference only the ID of the value with a foreign key.

Simple Way to Upload and Save File

Created 7 days ago by Misbahul D MunirTutorials0 comments – viewed 1,213 times – version 2.0
This tutorial need extension mdmsoft/yii2-upload-file. Follow the intruction to install. After installation done, create controller and action