/**
  * Render an element
  * @param object $element
  * @return string
  */
 protected function element($element)
 {
     // set id
     if (!isset($element->attributes['id'])) {
         $element->id = $this->id();
         $attributes = $element->attributes;
         $attributes['id'] = $element->id;
         $element->attributes = $attributes;
     } else {
         $element->id = $element->attributes['id'];
     }
     // set class
     if (!isset($element->attributes['class'])) {
         // set bootstap class
         $attributes['class'] = '';
     }
     // set label
     if (!$element->label) {
         if ($element->text) {
             $element->label = $this->_text->get($element->text);
         } else {
             $element->label = $this->_text->get('label.' . $element->key);
         }
     }
     // set error
     if ($error = $element->error()) {
         // create  errormessage
         $element->error = $this->_text->get('error.' . $element->key . '.' . $error);
     } else {
         $element->error = FALSE;
     }
     // set comment
     if (!isset($element->comment)) {
         if ($comment = $this->_text->get('comment.' . $element->key)) {
             $element->comment = $comment;
         } else {
             $element->comment = FALSE;
         }
     }
     // set default view
     $view = 'form/element';
     // render the element itself
     switch ($element->type) {
         case 'radio':
         case 'checkbox':
         case 'select':
             if (Arr::is_assoc($element->options) === FALSE) {
                 $options = array();
                 foreach ($element->options as $value => $label) {
                     $value = $label;
                     $label = $this->_text->get('option.' . $element->key . '.' . $value);
                     $options[$value] = $label;
                 }
                 $element->options = $options;
             }
             if ($element->type === 'radio') {
                 $view = 'form/radio';
             }
             if ($element->type === 'checkbox') {
                 $view = 'form/checkbox';
             }
             if ($element->type === 'select') {
                 if (isset($element->first_option)) {
                     $option = $element->first_option;
                     $value = is_array($option) && isset($option['value']) ? $option['value'] : $option;
                     $label = is_array($option) && isset($option['label']) ? $option['label'] : $this->_text->get('option.' . $element->key . '.' . $value);
                     // add to the beginning of options
                     $reverse = array_reverse($element->options, TRUE);
                     $reverse[$value] = $label;
                     $element->options = array_reverse($reverse, TRUE);
                 }
                 // set bootstap class
                 $attributes['class'] .= ' form-control';
                 $element->html = FormHTML::select($element->name, $element->options, $element->value, $attributes);
             }
             break;
         case 'hidden':
             $view = FALSE;
             $element->html = FormHTML::hidden($element->name, $element->value, $attributes);
             break;
         case 'submit':
             $view = FALSE;
             $label = isset($element->label) ? $element->label : $this->_text->get('label.' . $element->key);
             $element->html = FormHTML::submit($element->name, $label, $attributes);
             break;
         case 'btn':
             $view = FALSE;
             $label = isset($element->label) ? $element->label : $this->_text->get('label.' . $element->key);
             $href = isset($element->href) ? $element->href : '#';
             $element->html = HTML::anchor($href, $label, $attributes);
             break;
         case 'button':
             $view = FALSE;
             $label = isset($element->label) ? $element->label : $this->_text->get('label.' . $element->key);
             $element->html = FormHTML::button($element->name, $label, $attributes);
             break;
         case 'file':
             $element->html = FormHTML::file($element->name, $attributes);
             break;
         case 'image':
             $element->html = FormHTML::image($element->name, $element->value, $attributes, FALSE);
             break;
         case 'text':
         case 'password':
             if (!isset($attributes['placeholder'])) {
                 $attributes['placeholder'] = $this->_text->get('placeholder.' . $element->key);
             }
             // set bootstap class
             $attributes['class'] .= ' form-control';
             if ($element->type === 'text') {
                 $element->html = FormHTML::input($element->name, $element->value, $attributes);
             }
             if ($element->type === 'password') {
                 $element->html = FormHTML::password($element->name, $element->value, $attributes);
             }
             break;
         case 'textarea':
             $attributes['class'] .= ' form-control';
             $element->html = FormHTML::textarea($element->name, $element->value, $attributes, FALSE);
             break;
         default:
             $element->html = View::factory('form/' . $element->type, array('viewer' => $this, 'element' => $element))->render();
     }
     // wrap element
     if ($view) {
         $html = View::factory($view, array('element' => $element))->render();
     } else {
         $html = $element->html;
     }
     return $html;
 }
<?php

View::asset('js', URL::get('vendor') . 'tinymce/tinymce.min.js');
View::asset('js', URL::get('library') . 'js/backend/tinymce/yflink/plugin.js');
View::asset('js', URL::get('library') . 'js/backend/tinymce/yfimage/plugin.js');
View::asset('template', '<script class="yf" name="tinymce-image-default" type="text/html">
<img align="left" data-id="{{id}}" src="{{src}}" alt="{{title}}" data-size="{{size}}" data-enlarge="{{enlarge}}" />
</script>');
?>
<!-- Text area -->
<span class="yf" data-use="backend.form.Tinymce" data-template="tinymce-image-default" data-settings='<?php 
echo json_encode(array('tinymce' => array('mode' => 'textareas', 'selector' => '', 'content_css' => URL::get('base') . 'style/css/default.css,' . URL::get('base') . 'style/css/style.css,' . URL::get('base') . 'style/css/wysiwyg.css', 'convert_urls' => FALSE, 'force_p_newlines' => FALSE, 'language' => $_language, 'paste_word_valid_elements' => 'b,strong,i,em,h1,h2', 'menubar' => 'edit, insert, view, format, table', 'valid_elements' => 'object[height|width|style|data|type],param[name|value|style],embed[src|type|allowscriptaccess|allowfullscreen|width|height],span[name|value|style],strong/b,em/i,u/underline,a[href|target|id|class|title|data-id|style],p[style],h2[style],h3[style],hr[style],br,ul[style],ol[style],li[style],img[src|alt|title|align|width|height|id|class|rel|data-size|data-id|data-enlarge|style],table[style|width|height],tr[width|height],td[width|height|rowspan|colspan],th,tbody,sub,sup,iframe[src|width|height|frameborder|style],pre[style],div[class|style],blockquote[class|style],code[class|style]', 'toolbar1' => 'undo redo | styleselect | bold italic | bullist numlist | yflink yfimage | code', 'width' => '100%', 'height' => 400, 'plugins' => 'paste,media,table,yfimage,yflink,code'), 'url_link' => URL::to((isset($element->controller_link) ? $element->controller_link : 'link') . '@{{action}}:{{id}}', array('viewport' => 'item', 'callback' => '{{callback}}')), 'title_link' => text('link:module.single'), 'url_image' => URL::to((isset($element->controller_image) ? $element->controller_image : 'image') . '@embed:{{id}}', array('viewport' => 'item', 'param1' => '{{size}}', 'callback' => '{{callback}}')), 'title_image' => text('image:module.single'), 'path_images' => URL::get('files') . 'images/'));
?>
'>
	
	<?php 
echo FormHTML::textarea($element->name, HTML::chars($element->value), $element->attributes, FALSE);
?>
</span>