Dependent dropdownlist

How do I create dependent dropdownlist using constants and functions, without get the input from the tables.


    const TYPE_GENERAL = 'General Requirements for Electrical Inspections';

    const TYPE_WIRING = 'General Wiring Methods';

    const TYPE_BOXES = 'Boxes and Conduit Bodies';

    const TYPE_CABINETS = 'Cabinets and Cutout Boxes';

    const TYPE_SWITCHES = 'Switches and Receptacles';

    const TYPE_SERVICES = 'Services';

    const TYPE_FEEDERS = 'Feeders';

    const TYPE_CIRCUITS = 'Branch Circuits';

    const TYPE_SERVICE_GROUNDING = 'Service Grounding and Bonding';

    const TYPE_EQUIPMENT_GROUNDING = 'Equipment Grounding and Bonding';

    const TYPE_INDIVIDUAL = 'Individual';

    const TYPE_SERVICE = 'Service';

    const TYPE_COMMERCIAL = 'Commercial';

    const TYPE_INDUSTRIAL = 'Industrial';

    const TYPE_PUBLIC = 'Public';

    const TYPE_MULTINATIONAL = 'Multi-National';

    public static function getItemCategory()



        Yii::t('inspection', self::TYPE_GENERAL) => Yii::t('inspection', 'General Requirements for Electrical Inspections'),

        Yii::t('inspection', self::TYPE_WIRING) => Yii::t('inspection', 'General Wiring Methods'),

        Yii::t('inspection', self::TYPE_BOXES) => Yii::t('inspection', 'Boxes and Conduit Bodies'),

        Yii::t('inspection', self::TYPE_CABINETS) => Yii::t('inspection', 'Cabinets and Cutout Boxes'),

        Yii::t('inspection', self::TYPE_SWITCHES) => Yii::t('inspection', 'Switches and Receptacles'),

        Yii::t('inspection', self::TYPE_SERVICES) => Yii::t('inspection', 'Services'),

        Yii::t('inspection', self::TYPE_FEEDERS) => Yii::t('inspection', 'Feeders'),

        Yii::t('inspection', self::TYPE_CIRCUITS) => Yii::t('inspection', 'Branch Circuits'),

        Yii::t('inspection', self::TYPE_SERVICE_GROUNDING) => Yii::t('inspection', 'Service Grounding and Bonding'),

        Yii::t('inspection', self::TYPE_EQUIPMENT_GROUNDING) => Yii::t('inspection', 'Equipment Grounding and Bonding'),



    public static function getCorporationTypes()



        Yii::t('consumers', self::TYPE_INDIVIDUAL) => Yii::t('consumers', 'Individual'),

        Yii::t('consumers', self::TYPE_SERVICE) => Yii::t('consumers', 'Service'),

        Yii::t('consumers', self::TYPE_COMMERCIAL) => Yii::t('consumers', 'Commercial'),

        Yii::t('consumers', self::TYPE_INDUSTRIAL) => Yii::t('consumers', 'Industrial'),

        Yii::t('consumers', self::TYPE_PUBLIC) => Yii::t('consumers', 'Public'),

        Yii::t('consumers', self::TYPE_MULTINATIONAL) => Yii::t('consumers', 'Multi-National'),




        <div class="col-sm-6">

            <?= $form->field($model, 'item_category')->dropDownList($model->getItemCategory(),['prompt'=>Yii::t('inspection', '--- Please Select an Option ---')]); ?>


        <div class="col-sm-12 col-xs-4 col-lg-4">

             <?= $form->field($model, 'corporation_type')->dropDownList($model->getCorporationTypes(),['prompt'=>Yii::t('consumers', '--- Select Corporation Types ---')]); ?>


How do I make this drop down to depend on the other. That is getItemCategory() -> getCorporationTypes()

  1. How do I make a textinput to depend on dropdown.

There is a wiki on how to create dependent dropdowns

also just FYI you may have problems with this unless you are storing your information translated.

Yii::t('consumers', self::TYPE_MULTINATIONAL) => Yii::t('consumers', 'Multi-National')

i think a better way would be to store the information not translated and then translate it on the fly to whatever the requested language is.

self::TYPE_MULTINATIONAL => [/size][size=2]Yii::t('consumers', self::TYPE_MULTINATIONAL)