<?php
namespace modules\custom\widgets;

use yii;
use yii\helpers\{ArrayHelper, Html,Json};
use yii\widgets\InputWidget;
use backend\models\Productsbe;

/**
 * TinyMCE renders a tinyMCE js plugin for WYSIWYG editing.
 */
class CameraInput extends InputWidget
{
    //Callback function
    public $productid;
    public $assetid;
    public $name = 'CameraInput';
    public $model;
    public $form;
    public $relatedto;
    public $relatedid;

    public function run()
    {
        
      //  $this->registerClientScript();
        return $this->render('@modules/custom/widgets/assets/_camera', []);
    }
    
    /**
     * Registers Twitter TypeAhead Bootstrap plugin and the related events
     */
    protected function registerClientScript()
    {
        $this->view->registerJs("var relatedid = '".$this->relatedid ."'", yii\web\View::POS_BEGIN, 'relatedid');
        $this->view->registerJs("var relatedto = '".$this->relatedto ."'", yii\web\View::POS_BEGIN, 'relatedto');
        $cam = Yii::$app->assetManager->publish(__DIR__.'/assets/camera.js');
        $this->view->registerJSFile($cam[1],['position' =>  yii\web\View::POS_END]);
        CameraInputAssets::register($this->view);

    }
}
