Yii2 request parameter from url
Asked 07 September, 2021
Viewed 2.4K times
  • 57
Votes

In YII I could request a parameter from url and populate a form field called companyAdd_id with the following code, trying to do the same in YII2 but getting errors, looking for advice on how to do the same in YII2. thanks

<?php echo $companyAdd_id = Yii::app()->request->getParam('companyAdd_id'); ?>

<?php echo $form->hiddenField($model, 'companyAdd_id', array(
        'type'  => 'text',
        'value' => $companyAdd_id
)); ?>

<?php echo $form->error($model, 'companyAdd_id'); ?>

4 Answer