<?php

namespace GriffinForms\Admin\Html\FormControls\Field\ValidationTraits;

trait TextArea
{
    public $min_chars_textarea;
    protected $max_chars_textarea;
    
    public function setMinCharsTextArea()
    {
        $this->min_chars_textarea = $this->fixEmptyValue('min_chars', '');
    }
    
    protected function setMaxCharsTextArea()
    {
        $this->max_chars_textarea = $this->fixEmptyValue('max_chars', '');
    }
    
    private function minCharsTextArea()
    {
        $field = new \GriffinForms\Admin\Html\FormControls\InputNumber('min_chars', $this->min_chars_textarea);
        echo '<div class="">';
        echo esc_html($this->lang->getText('min_chars'));
        echo '</div>';
        echo '<div class="mb-2">';
        $field->html();
        echo '</div>';
    }
    
    private function maxCharsTextArea()
    {
        $field = new \GriffinForms\Admin\Html\FormControls\InputNumber('max_chars', $this->max_chars_textarea);
        
        echo '<div class="">';
        echo esc_html($this->lang->getText('max_chars'));
        echo '</div>';
        echo '<div class="">';
        $field->html();
        echo '</div>';
    }
    
    protected function validationOptionsTextArea()
    {
        echo '<div class="row">';
        
        echo '<div class="col-md-12 gf-validation-options" id="gf-custom-parameters-wrap">';
        
        $this->minCharsTextArea();
        $this->maxCharsTextArea();
        
        echo '</div>';
        
        echo '</div>';
    }
}