<?php

namespace {{studly_author}}\{{studly_plugin}}\FormWidgets;

use Backend\Classes\FormWidgetBase;

/**
 * {{name}} Form Widget
 */
class {{studly_name}} extends FormWidgetBase
{
    /**
     * @inheritDoc
     */
    protected $defaultAlias = '{{lower_author}}_{{lower_plugin}}_{{snake_name}}';

    /**
     * @inheritDoc
     */
    public function init()
    {
    }

    /**
     * @inheritDoc
     */
    public function render()
    {
        $this->prepareVars();
        return $this->makePartial('{{lower_name}}');
    }

    /**
     * Prepares the form widget view data
     */
    public function prepareVars()
    {
        $this->vars['name'] = $this->formField->getName();
        $this->vars['value'] = $this->getLoadValue();
        $this->vars['model'] = $this->model;
    }

    /**
     * @inheritDoc
     */
    public function loadAssets()
    {
        $this->addCss('css/{{lower_name}}.css', '{{author}}.{{plugin}}');
        $this->addJs('js/{{lower_name}}.js', '{{author}}.{{plugin}}');
    }

    /**
     * @inheritDoc
     */
    public function getSaveValue($value)
    {
        return $value;
    }
}
