Changes
                            
    Title
    changed
    How to user an application behavior forto maintain runtime configuration
    Category
    unchanged
    How-tos
    Yii version
    unchanged
    
    Tags
    unchanged
    application, configuration, behavior
    Content
    changed
    In this tutorial will be explained a method 
forto manage some configuration runtime. [This excellent tutorial](http://www.yiiframework.com/wiki/26/setting-and-maintaining-the-language-in-application-i18n "") follows a similar approach, but requires to write a masterclass w
hich all controllers are supposed to extend, following this wiki you can achi
eve the same 
by only editing 
only the configuration.
This is often needed 
forto manage internationalization, themes and other conf
iu
gration that depends from the user.
The most co
nmfortable way is to user an application behavior. In this example we save the language in the session, but 
it can also be saved in 
the database.
Create a file in compo
mnents named ApplicationConfigBehavior and copy this code
 in it:
```php[...]
/**
 * ApplicationConfigBehavior is a behavior for the application.
 * It loads additional config paramenters that cannot be statically 
 * written in config/main
 */[...]
/**
     * Declares events and the event handler methods
     * See yii documentation on behaviour
     */
    public function events()[...]
ForTo update the language we can use a widget (to be included in layout/main), for example:[...]
<?php echo CHtml::form(); ?>
    <div id="langdrop">
        <?php echo CHtml::dropDownList('_lang', $currentLang, array(
            'en_us' => 'English', 'is_is' => 'Icelandic'), array('submit' => '')); ?>
    </div>
<?php echo CHtml::endForm(); ?>
```