Wiki

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

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

Created 2 years ago by c@cbaTutorials10 comments – viewed 27,208 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.

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

Created 5 months ago by Kartik VHow-tos10 comments – viewed 5,879 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.

Fixing extensions without modifying their code

Created about a year ago by schmunkTips3 comments – viewed 5,876 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.

How to use an application behavior to maintain runtime configuration

Created 3 years ago by zaccariaHow-tos3 comments – viewed 24,410 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.

Rendering a view file in a console application

Created 2 years ago by TompiHow-tos1 comment – viewed 7,890 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,382 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.

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

Created about a year ago by le_topTips0 comments – viewed 6,615 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,403 times – ( +5 ) – version 1.1
This page explains how to implement an event and catch that event in a behavior.
tags: event, behavior

Simple Way to Upload and Save File

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