我如何将下拉列表中的值存储到条形码小部件中?

时间:2016-12-22 07:23:09

标签: php yii2

我需要将选定的产品代码从下拉列表传输到条形码生成器。

<?php $dataStorageLocation = ArrayHelper::map(StorageLocation::find()>all(),'storage_id','storage_id'); ?>

<?php $form = ActiveForm::begin(); ?>
<div class="col-sm-12 col-xs-12">    

  <?= $form->field($model, 'product_code', ['template' => '<div class="col-sm-3         text-right">{label}</div><div class="col-sm-9 col-xs-12">{input}</div>{hint}        {error}'])->dropDownList($dataStorageLocation);

$optionsArray = array(
'elementId'=> 'showBarcode', /* div or canvas id*/
'value'=> '$model', /* value for EAN 13 be careful to set right values for each barcode type */
'type'=>'code128',/*supported types  ean8, ean13, upc, std25, int25, code11, code39, code93, code128, codabar, msi, datamatrix*/

);
echo BarcodeGenerator::widget($optionsArray); ?>

</div> 

1 个答案:

答案 0 :(得分:0)

我只在值中添加$ model-&gt; product_code。