Jump to content


textarea with ckeditor/tinymce does not save data

tinymce ckeditor data not saved

  • Please log in to reply
7 replies to this topic

#1 bluepicaso

bluepicaso

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationIndia

Posted 14 July 2014 - 10:31 AM

simple,

If i implement any editor and HTML from the html view or the source view. the content is not saved.

 

screenshot-testmybug com 2014-07-14 15-44-20.png


3hbYu9D.jpg

Attached Thumbnails

  • screenshot-testmybug com 2014-07-14 15-44-20.png

Harpreet Singh Bhatia
[web developer, programmer, entrepreneur]
Portfolio: TheCodingBox


Follow Me: facebook.png twitter.png googleplus.pngskype.png


#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 14 July 2014 - 03:51 PM

that should not be practically the problem.. check up what all data is being posted.. !!

also.. do share in the code and table structure and we might be able 2 help u



#3 bluepicaso

bluepicaso

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationIndia

Posted 15 July 2014 - 10:11 AM

that should not be practically the problem.. check up what all data is being posted.. !!

also.. do share in the code and table structure and we might be able 2 help u

table structure
aImSnAOl.jpg

Code:
 

public function manageEmailers() {
    if(checkSession()){
      $this->load->library('grocery_CRUD');
      $crud = new grocery_CRUD();
      $crud->set_theme('flexigrid');
      $crud->set_table('emailers');
      $crud->columns('email_subject', 'trigger_on', 'is_active');
      $crud->field_type('is_active','dropdown',array('0'=>'no', '1' => 'yes'));
      $crud->required_fields('email_subject', 'email_body', 'static_text');
      $crud->columns('email_subject', 'email_body', 'trigger_on');
      $state = $crud->getState();
      if($state == 'add' || $state == 'edit'){ 
        $data['admin_js'] = "jQuery(document).ready(function() {jQuery('#email_body_input_box').prepend('<div class=\'admin_notice\'><b>Dynamic keywords:</b> {site_url}, {activation_link}, {user_full_name}, {user_profile_link}, {daily_v_convos}, {static_text} <br> <b>Usage syntax : welcome {user_full_name}, thank you </b> </div>');});";
      }
      $crud->set_js('js/crud.js');
      $crud->post_ajax_callbacks('trigLinks()');
      $crud->unset_read();
      $crud->unset_delete();
      $crud->unset_texteditor('email_body');
      
      $output = $crud->render();
      $data['title']="Manage Emailers";
      $data['adminMenu']=1;
      $output = array_merge($data,(array)$output);
      $this->_outputData($output);
    }
    else{
      $this->session->set_flashdata('msg', 'Your session has expired please login again');
      redirect('welcome/index');
      return;
    }
  }

Harpreet Singh Bhatia
[web developer, programmer, entrepreneur]
Portfolio: TheCodingBox


Follow Me: facebook.png twitter.png googleplus.pngskype.png


#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 15 July 2014 - 10:24 PM

well... if you notice the post in the firebug when u submitting the data .. it is looking for value in email_body

where as as per the code it seems the value is being collected into email_body_input_box - now both are separate fields all together..

it is possible you trying to control the field output to the set text editor using the js file.. but you not getting the same field name.. rather getting it as another field name. My recomendation - do maintain the field name .. or remove the email_body as compulsary field

Secondly.. do add a callback_before_insert

where u 1st copy the content of new field set to email_body

secondly - remove the new field as it is not there in table it will throw up error

 

Hope the soltuion works 4 u...

 

Happy GCing:)



#5 bluepicaso

bluepicaso

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationIndia

Posted 25 July 2014 - 07:27 AM

alright its saving now. but here is another problem.
Its not saving the inline style of a copy pasted html code, even when i paste it in the source as html itself..

Any good reasons?


Harpreet Singh Bhatia
[web developer, programmer, entrepreneur]
Portfolio: TheCodingBox


Follow Me: facebook.png twitter.png googleplus.pngskype.png


#6 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 25 July 2014 - 03:45 PM

Well to my understanding.. if u analyze / realize the code that gets stored in backend.. the html in it is having the html tags converted to special chars so b4 u display it back.. use html_entity_decode for it.. !!! That should work 4 u..!!



#7 bluepicaso

bluepicaso

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationIndia

Posted 28 July 2014 - 06:29 AM

Solution found at

http://blog.codebust...st-after-update

 create a file called "MY_Security.php" in application/code

code

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
*
* Extend Security controller
*
*/

class MY_Security extends CI_Security
{
function __construct()
{
parent::__construct();
}

protected function _remove_evil_attributes($str, $is_image)
{
// All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns
$evil_attributes = array('on\w*', 'xmlns');

if ($is_image === TRUE)
{
/*
* Adobe Photoshop puts XML metadata into JFIF images,
* including namespacing, so we have to allow this for images.
*/
unset($evil_attributes[array_search('xmlns', $evil_attributes)]);
}

do {
$str = preg_replace(
"#<(/?[^><]+?)([^A-Za-z\-])(".implode('|', $evil_attributes).")(\s*=\s*)([\"][^>]*?[\"]|[\'][^>]*?[\']|[^>]*?)([\s><])([><]*)#i",
"<$1$6",
$str, -1, $count
);
} while ($count);

return $str;
}

}

thats it.


Harpreet Singh Bhatia
[web developer, programmer, entrepreneur]
Portfolio: TheCodingBox


Follow Me: facebook.png twitter.png googleplus.pngskype.png


#8 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 28 July 2014 - 07:54 AM

great.. good work... thank you for sharing it might help others too :)







Also tagged with one or more of these keywords: tinymce, ckeditor, data, not, saved

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users