Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By davidboris

Thread: Render HTML in text area

  1. #1
    jeremy.roberts is offline Junior Member
    Join Date
    Oct 2009
    Posts
    4

    Default Render HTML in text area

    Hi,
    I have a textarea field that is populated programmtically with a HTML table. Prior to v6, I had to have a custom view and wrap this field in the from_html function to render the HTML table correctly.

    However, since upgrading to 6, the table won't render - just shows HTML code.

    It seems that all textarea fields escape html in the detail view. Is there any way to override this? I've tried manipulating the detailviewdefs in the view to have displayParams['htmlescape'] = false, but no good. It seems the base field adds the htmlescape = true back into the displayParams (include/SugarFields/Fields/Text/SugarFieldText.php).

    Anyone know how to do this in an upgrade safe way?

    Thanks.

  2. #2
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: Render HTML in text area

    Hello,

    Try our new plug-in WYSIWYG
    mlorca likes this.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  3. #3
    smbslt42 is offline Sugar Community Member
    Join Date
    Sep 2010
    Posts
    28

    Default Re: Render HTML in text area

    Were you ever able to resolve this?

    Quote Originally Posted by jeremy.roberts View Post
    Hi,
    I have a textarea field that is populated programmtically with a HTML table. Prior to v6, I had to have a custom view and wrap this field in the from_html function to render the HTML table correctly.

    However, since upgrading to 6, the table won't render - just shows HTML code.

    It seems that all textarea fields escape html in the detail view. Is there any way to override this? I've tried manipulating the detailviewdefs in the view to have displayParams['htmlescape'] = false, but no good. It seems the base field adds the htmlescape = true back into the displayParams (include/SugarFields/Fields/Text/SugarFieldText.php).

    Anyone know how to do this in an upgrade safe way?

    Thanks.

  4. #4
    lijith's Avatar
    lijith is offline Sugar Community Member
    Join Date
    Jun 2009
    Location
    India
    Posts
    67

    Default Re: Render HTML in text area

    Did any one have a solution for this one.
    I have to use html tags on the description fields. How can I use that.
    Lijith M Gopinath
    email : phpbugs@live.com
    website : PHP-Bugs

  5. #5
    rafael.q.g@hotmail.com's Avatar
    rafael.q.g@hotmail.com is offline Sugar Community Member
    Join Date
    Jun 2011
    Location
    Florianópolis - Brazil
    Posts
    782

    Default Re: Render HTML in text area

    Try to use tinymce javascript library.
    It provides an text editor on web (very light, developed just with javascript), that enables the user to enhance the text like in Microsoft word or others text processor tools, and returns the content in HTML format.
    So you can plug this library at your code, use it to renderize your text area, without need to change any code in other layers.

    Here is the tool web site: http://tinymce.moxiecode.com/
    Rafael Queiroz Gonçalves
    Advanced OMG UML Certified Professional
    Sun Certified Enterprise Architect for the Java Platform
    Sun Certified Programmer for the Java 2 Platform
    IBM Certified Advanced Application Developer - Lotus Notes and Domino
    IBM Certified Application Developer - IBM WebSphere Portlet Factory
    Computer Science Mastering / UFSC - PPGCC

  6. #6
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Render HTML in text area

    Actually SugarCRM already supports TinyMCE, you just need to load it into constructor of view edit:

    PHP Code:
         function CasesViewEdit(){
        
            
    //Show mce edit on content field
            
    require_once('include/SugarTinyMCE.php');
            
    $tiny = new SugarTinyMCE();
            
    $tiny->defaultConfig['height'] = '300';
            
    $tiny->defaultConfig['width'] = '60%';
            
    $tiny $tiny->getInstance("description");
            echo 
    $tiny;
            
             
    parent::ViewEdit();
         } 
    Regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  7. #7
    lijith's Avatar
    lijith is offline Sugar Community Member
    Join Date
    Jun 2009
    Location
    India
    Posts
    67

    Default Re: Render HTML in text area

    I want this only on the detail view.
    I solved this using jQuery to replace the text &lt; to < and &gt; to >

    Thanks for your info.
    Lijith M Gopinath
    email : phpbugs@live.com
    website : PHP-Bugs

  8. #8
    crucialvacuum is offline Junior Member
    Join Date
    Jun 2011
    Posts
    1

    Default Re: Render HTML in text area


  9. #9
    mlorca's Avatar
    mlorca is offline Member
    Join Date
    Apr 2007
    Location
    Santiago, Chile
    Posts
    10

    Default Re: Render HTML in text area

    Quote Originally Posted by davidboris View Post
    Hello,

    Try our new plug-in WYSIWYG
    Guys, the solution proposed by David Bories is really great. I installed the module in CE 6.2.3 and applied the new 'wysiwyg' field type to existing 'description' field of Documents module and worked like a charm instantly.
    Thanks for a very well done job David.

  10. #10
    mlorca's Avatar
    mlorca is offline Member
    Join Date
    Apr 2007
    Location
    Santiago, Chile
    Posts
    10

    Smile Re: Render HTML in text area

    Quote Originally Posted by lijith View Post
    Did any one have a solution for this one.
    I have to use html tags on the description fields. How can I use that.
    Hi Lijith:

    Definitively, the best solution I found is composed by the WYSIWYG module from David Bories (Post #2 in this page) and a little customization to the "description" field, let's say from Documents module. I created the file custom/Extension/modules/Documents/Ext/Vardefs/description_customized.php to contain the following customizations:

    PHP Code:
    // created: 2011-10-20 23:00
    $dictionary['Document']['fields']['description'] = array(
      
    'name' => 'description',
      
    'vname' => 'LBL_DESCRIPTION',
      
    'type' => 'wysiwyg',
      
    'dbType' => 'text',
      
    'required' => true,
      
    'source' => 'custom_fields',
      
    'id' => 'Documentsdescription',
      
    'custom_module' => 'Documents',
      
    'massupdate' => '0',
      
    'default' => NULL,
      
    'comments' => 'From now on, you can create rich text contents for your descriptions',
      
    'help' => 'Use the WYSIWYG editor to use text, tables, images and a lot more in this description',
      
    'importable' => 'true',
      
    'duplicate_merge' => 'disabled',
      
    'duplicate_merge_dom_value' => '0',
      
    'audited' => true,
      
    'reportable' => true,
    ); 
    Then a QuickRepair and voilá!, your description field is now HTML able

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 2009-09-29, 11:15 AM
  2. Client found response content type of 'text/html', but expected 'text/xml'
    By jitchavan in forum Installation and Upgrade Help
    Replies: 0
    Last Post: 2008-07-11, 07:05 AM
  3. Replies: 0
    Last Post: 2008-07-11, 06:06 AM
  4. Replies: 0
    Last Post: 2008-07-11, 06:04 AM
  5. Email module - no HTML text area for email body
    By marcuscherry in forum Help
    Replies: 1
    Last Post: 2007-08-17, 01:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •