<?php

/*
 * PuzzleApp
 * Webemyos
 * Jérôme Oliva
 * GNU Licence
 */

namespace Apps\DownloadManager\Widget\DownloadManagerEmailDownloadForm;

use Core\Control\Form\Form;
use Core\View\View;
use Core\View\ElementView;

class DownloadManagerEmailDownloadForm extends Form {

    function __construct($core = "", $token = "") {
        $this->Core  = $core;
        $this->Token = $token;
        $this->Init();
    }

    function Init($data = "") {

        $this->form = new Form("DownloadManagerEmailDownloadForm", $data);
        $this->form->SetView(__DIR__ . "/View/index.tpl", $this->Core);

        $this->form->Add([
            "Type"       => "TextBox",
            "Id"         => "Email",
            "Validators" => ["Required"],
        ]);

        $this->form->Add([
            "Type"       => "Hidden",
            "Id"         => "Token",
            "Value"      => $this->Token
        ]);

            
        $this->form->Add([
            "Type"     => "Button",
            "Id"       => "btnDownload",
            "Value"    => $this->Core->GetCode("DownloadManager.Download"),
            "CssClass" => "btn btn-primary"
        ]);
    }

    function Render() {
        return $this->form->Render();
    }

    function Validate($data = "") {
        return $this->form->Validate($data);
    }
}

?>
