<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
<?
global $db;
ob_start();
?>
  <?= \Html::input(
              array(
                'label'     => 'Nazwa',
                'name'      => 'name',
                'id'        => 'name',
                'value'     => $this -> email_template['name'],
                'inline'    => true,
                'readonly'  => $this -> email_template['is_admin'] ? true : false
              )
             );?>
  <?= \Html::textarea(
              array(
                'label'   => 'Treść',
                'name'    => 'text',
                'id'      => 'text',
                'value'   => $this ->email_template['text'],
                'inline'  => true
              )
          );?>

<?
$out = ob_get_clean();
$grid = new \gridEdit;
$grid -> id               = 'email-templates-edit';
$grid -> gdb_opt          = $gdb;
$grid -> include_plugins  = true;
$grid -> title            = 'Edycja szablonu newslettera';
$grid -> fields           = [
                              [
                                'db' => 'id',
                                'type' => 'hidden',
                                'value' => $this -> email_template['id']
                              ]
                            ];
$grid -> external_code    = $out;
$grid -> actions          = [ 
                              'save' => [ 
                                'url'       => '/admin/newsletter/template_save/',
                                'back_url'  => $this -> email_template['is_admin'] ? '/admin/newsletter/email_templates_admin/' : '/admin/newsletter/email_templates_user/'
                              ], 
                              'cancel' => [ 
                                'url' => $this -> email_template['is_admin'] ? '/admin/newsletter/email_templates_admin/' : '/admin/newsletter/email_templates_user/'
                              ] 
                            ];
$grid -> persist_edit     = true;
$grid -> id_param         = 'id';

echo $grid -> draw();
?>
<script type="text/javascript">
  $( function() {
    $( '#text' ).ckeditor( {
      toolbar : 'MyTool',
      height:'350'
    });
  });
</script>