Additional hidden field with radio button set default value in yii2

additional hidden field with radio button set default value in yii2

you will see yii automatically adds hidden field with each radio button and checkbox , you can set its default value by following code

1<?= $form->field($model, 'session_frequency_id')->radio(['uncheck' => 1, 'label' => 'Daily', 'value' => 1, 'class' => 'icheck toggle-able sessionhost-session_frequency_id' ] ) ?>

in above code uncheck => 1 will set hidden field value .

magento 1 create admin user programmatically


    $mageFilename = 'app/Mage.php';

    if (!file_exists($mageFilename)) {

        echo $mageFilename." was not found";



    require_once $mageFilename;


    try {

        //create new user by providing details below

        $user = Mage::getModel('admin/user')


                'username' => 'admin1',

                'firstname' => 'John',

                'lastname' => 'Doe',

                'email' => '',

                'password' => 'welcome123',

                'is_active' => 1


    } catch (Exception $e) {

        echo $e->getMessage();



    try {

        //create new role

        $role = Mage::getModel("admin/roles")




        //give "all" privileges to role





    } catch (Mage_Core_Exception $e) {

        echo $e->getMessage();


    } catch (Exception $e) {

        echo 'Error while saving role.';



    try {

        //assign user to role




    } catch (Exception $e) {

        echo $e->getMessage();



    echo 'Admin User sucessfully created!';



Executing cron tasks manually in Magento

For example, we have this cron task on a config.xml file of a specific module:

1<catgento_sap_sync_nonimages><schedule><cron_expr>*/15 * * * *</cron_expr></schedule><run><model>sap/cron_sync_nonimages::run</model></run></catgento_sap_sync_nonimages>

we can create a new script that loads and executes that cron task like this (create a script.php file and put something like this inside):

1234567<?php//Load Magento APIrequire_once'app/Mage.php';Mage::app();//First we load the model$model= Mage::getModel('sap/cron_sync_nonimage');//Then execute the task$model->run();

The last step would be running this script manually (php script.php).

magento 1 clear cache command line

I have resolved the issue by myself with the following solution:

Login to your server and run the below command from your Magento root directory:

 php -r 'require "app/Mage.php"; Mage::app()->getCacheInstance()->flush();' 

Above command flush your Magento 1 cache. I suggest when changing Magento project folder then run the above command

How to Switch PHP Version on an Ubuntu 18.04


In this post, we will illustrate how to switch PHP version from 7.2 to 5.6 to enable you to run your projects smoothly with the help of just one command.


  • Ubuntu 18.04 operating system
  • Web server.
  • A non-root user with sudo privileges.
  • Have 2 different versions of PHP installed on your machine


Upgrade your system packages

1$ sudo apt upgrade

Note: This tutorial assumes you have already installed PHP 5.6 and 7.2, but in case you do not have any two PHP versions installed on your computer, we will be working with versions 7.0 and 7.2. You can use the following commands  to install them:

1$ sudo apt install python-software-properties
1$ sudo add-apt-repository ppa:ondrej/php
1$ sudo apt install php7
1$ sudo apt install php7

Run the command to check the set default version of PHP

1$ php -v

By default, Ubuntu will set the latest, stable version of PHP as the default i.e. version 7.2. To switch to the alternative version (5.6)

1$ sudo a2dismod php7
1$ a2enmod php7
1$ sudo service apache2 restart
1$ sudo update-alternatives --set php /usr/bin/php7

Note: If you are using Nginx server, you can restart it by using the following command:

1$ sudo systemctl restart nginx

You will notice the version has changed from version 7.2 to 5.6. Of course, the opposite can be done by following the steps above and replacing the version of PHP in each step and voila! You are back to your previous version.

This process may seem repetitive and tedious, so to make it easy, you can encapsulate the entire process in a function. To do this, open your .bashrc file with your favorite editor, in this case, we use nano.

1$ sudo vim~/.bashrc

Copy the below code in .bashrc file:

12345678910111213141516changephpversion () {                local IS_PHP7=`php -version|grep "PHP 7.2"`                if [[ -z $IS_PHP7 ]] ; then                            echo "Switching... Please wait"                            sudo a2dismod php7.0;                            sudo a2enmod php7.2;                            sudo service apache2 restart                            sudo update-alternatives --set php /usr/bin/php7.2                else                            echo "Switching... Please wait"                            sudo a2dismod php7.2;                            sudo a2enmod php7.0;                            sudo service apache2 restart                            sudo update-alternatives --set php /usr/bin/php7.0                fi}

Exit your editor while saving changes and incorporate the new changes by typing below command:

Now when you type changephpversionon in your terminal, the function will automatically switch PHP version and will also reduce a lot of manual work.


You can try out this tutorial with different PHP versions according to your requirements. Very simple indeed!

Happy coding.