⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to set the texteditor type by field



davidoster

davidoster
  • profile picture
  • Member

Posted 29 June 2013 - 04:45 AM

Hello all.

Recently I came across a requierement where I need to be able to set a certain field or fields with a specific type of texteditor,

 

e.g. I have a table customers which has

- a field address which I want it to be displaying the minimal version of the texteditor (check under application/config/grocery_crud.php for the different options)

- a field additional_info which I want it to be displaying the full version

 

I could hack in a couple of places the Grocery CRUD library itself but I don't want to do this.

I am sure there must be a very easy way of doing this!

Any thoughts?


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 01 July 2013 - 04:11 AM

Well, there surely looks to have a way...

As newer version of grocery crud looks up on using ckeditor rather then tinymce editor, here is a basic example that  can be used up

 

One example shared -  http://ckeditor.com/demo#toolbar   - But extracting the stuff from there surely is going to be a pain...

 

Here is what you can try... create one custom js and add it to the page you calling.. there..

window.onload = function ()
{
//Define the config's

  var basicConfig = {
    height: 100,
    plugins: 'about,basicstyles,clipboard,list,indent,enterkey,entities,link,pastetext,toolbar,undo,wysiwygarea',
    forcePasteAsPlainText : true,
    removeButtons: 'Anchor,Underline,Strike,Subscript,Superscript',
    toolbarGroups: [
      { name: 'document',       groups: [ 'mode', 'document', 'doctools' ] },
      { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
      { name: 'forms' },
      { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
      { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align' ] },
      { name: 'links' },
      { name: 'insert' },
      { name: 'styles' },
      { name: 'colors' },
      { name: 'tools' },
      { name: 'others' },
      { name: 'about' }
    ]
  };

  var fullConfig = {
    height: 300,
    plugins: 'about,a11yhelp,basicstyles,bidi,blockquote,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,floatingspace,font,format,forms,horizontalrule,htmlwriter,image,iframe,indent,justify,link,list,liststyle,magicline,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,resize,save,scayt,selectall,showblocks,showborders,smiley,sourcearea,specialchar,stylescombo,tab,table,tabletools,templates,toolbar,undo,wsc,wysiwygarea',
    removeButtons: '',
    toolbarGroups: [
      { name: 'document',       groups: [ 'mode', 'document', 'doctools' ] },
      { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
      { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
      { name: 'forms' },
      '/',
      { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
      { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
      { name: 'links' },
      { name: 'insert' },
      '/',
      { name: 'styles' },
      { name: 'colors' },
      { name: 'tools' },
      { name: 'others' },
      { name: 'about' }
    ]
  };
 
 //Standard one anyways is not required to define.. or whatever is required, can be defined the way it is required for..
	$('#editor1').ckeditor(basicConfig);
	$('#editor2').ckeditor(fullConfig);
}

This should help you reach your solution ...


davidoster

davidoster
  • profile picture
  • Member

Posted 02 July 2013 - 08:47 AM

Thanks [member=amit shah].

Yes for CKEditor(which I currently use) this is one way of doing it! 

 

Now the thing is I am aiming to a more global approach so we can share with everybody ewhich applies to all the editors...

 

Thank you anyway for this though!

 

 

P.S. I was thinking to manipulate via jQuery the class of the text fields (this is what get_text_input does) but then I need to refresh and the change will be lost!