<?php


namespace App\Components\Forms;

use NasExt\Forms\Controls\DependentSelectBox;
use Nette;
use Nette\Application\UI\Form;
use Nette\ComponentModel\IContainer;
use RadekDostal\NetteComponents\DateTimePicker\TbDatePicker;
use RadekDostal\NetteComponents\DateTimePicker\TbDateTimePicker;
use xhulav\BootstrapForms\BootstrapControls;
use xhulav\BootstrapForms\IBootstrapForm;
use xhulav\BootstrapForms\Rendering\BootstrapFormRenderer;
use Zet\FileUpload\FileUploadControl;

/**
 * Class BootstrapForm
 * @package App\Components\Forms
 * @method FileUploadControl addFileUpload($name, $maxFiles = 25, $maxFileSize = NULL)
 * @method DependentSelectBox addDependentSelectBox($name, $label = NULL, array $parents, callable $dependentCallback, $multiple = FALSE)
 */
class BootstrapForm extends Form implements IBootstrapForm
{
    public function __construct(IContainer $parent = null, $name = null)
    {
        parent::__construct($parent, $name);

        $this->setRenderer(new BootstrapFormRenderer());
    }

    use BootstrapControls;

    public function addDatetimePicker($name, $label = NULL, $maxLength = NULL)
    {

        $control = new TbDateTimePicker($label, $maxLength);
        $control->setAttribute('class', 'form-control datetimepicker');
        return $this[$name] = $control;
    }

    public function addDatePicker($name, $label = NULL, $maxLength = NULL)
    {
        $control = new TbDatePicker($label, $maxLength);
        $control->setAttribute('class', 'form-control datepicker');
        return $this[$name] = $control;
    }
}