<?php

namespace GriffinForms\Admin\Html\FormControls;

class TextArea extends \GriffinForms\Admin\Html\FormControls\Format
{
    protected $rows;

    protected function setCssClass()
    {
        if (!empty($this->data['app_context'])) {
            $this->css_class = 'class="form-control gf-app-control-input griffinforms-' . $this->purgeString($this->name) . ' griffinforms-' . strtolower($this->meta) . ' griffinforms-formcontrol"';
        }
    }

    protected function setRows()
    {
        if(isset($this->data['rows']) and is_numeric($this->data['rows'])) {
            $this->rows = $this->data['rows'];
        } else {
            $this->rows = 5;
        }
    }
    
    public function html()
    {
        echo '<textarea ' . wp_kses_post($this->attr_name) . ' ';
        $this->getAttr('css_class');
        $this->getAttr('css_id');
        echo 'rows="' . absint($this->rows) . '"';
        echo '>' . esc_html($this->value) . '</textarea>';   
    }
}
