<?php 

class NoteTextArea  {
  private $field;
  private $label;
  private $form;
  private $areaRows;

  public function __construct($field) {

    if (isset($field)) {
      $this->field    = $field->field;
      $this->form = $field->form;
      $this->areaRows = $field->areaRows;

      if (isset($field->label))
        $this->label = "<label>$field->label</label><br>";
      else
        $this->label = "";
              
      if (isset($field->placeholder))
        $this->placeholder = "placeholder='$field->placeholder'";
      else
        $this->spaceholder = "";
    }
  }

  public function outputLayout() {


    $layout = "

$this->label    
<textarea rows='$this->areaRows' id='$this->field' class='$this->form'
  name='$this->field' $this->placeholder></textarea>

     ";
  
 	return $layout;
  }	

  public function outputScript() {

	$script = "

$(document).ready(function() {

  if ('$this->dbValue' != '') {
    set$this->field ('$this->dbValue', '', 'formentry');
    send$this->field ('$this->entry', '');
  }
});

$(document).on('change', '#$this->field', function (e) {
  send$this->field ($(this).val(), '');
});

function set$this->field (value, text, source) {
  document.getElementById('$this->field').value = value;
}

multiFunction['set$this->field'] = {
  set$this->field: set$this->field
};  

function send$this->field (value, text) {
  var msgContent = [];
  msgContent.$this->field = [value, text, 'formentry', '$this->field', 'new field value'];
  newValue$this->form (msgContent);
}


	  
    "; 
    return $script;
  }
}

?>