ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

SafeCracker, textareas, and text formatting

October 01, 2012 5:13pm

Subscribe [2]
  • #1 / Oct 01, 2012 5:13pm

    Tim Murtaugh

    52 posts

    Perhaps I am missing it, but I can’t find any reference to working with text formatting within a SafeCracker form.

    I have a working form, but the main content field of the entries are a textarea with XHTML formatting applied.

    When I output the field like so (the simplest way):

    <textarea name="article_content">{article_content}</textarea>

    ... the field’s content comes through with P tags intact. This means that when I save the article, the P tags are now in the entry data.

    I tried a few permutations of tags I found in the documentation, without results. I tried using the custom_fields loop, but I guess I’m unclear as to how it works — it’s an all or nothing thing?

  • #2 / Oct 03, 2012 10:39am

    Shane Eckert

    7174 posts

    Hello Tim,

    I am not sure how those tags are getting in there.

    Can I see the whole form?

    Can you show me a screenshot with an example of the behavior you are seeing?

    Thank you,

  • #3 / Oct 03, 2012 2:00pm

    Tim Murtaugh

    52 posts

    Hi Shane,

    Here’s the form in question:

    {exp:channel:entries channel="columns" url_title="{segment_3}" limit="1" disable="categories|category_fields|member_data"}
    
    {exp:safecracker channel="columns" return="/edit/column/{url_title}/submitted" include_jquery="no" safecracker_head="no" class="editForm" id="editForm{entry_id}" entry_id="{entry_id}"}
     
     <header data-title="title">
     
      <h1><input name="title" type="text" value="{title}"></h1>
      
      
       URL Title: <input name="url_title" type="text" value="{url_title}">
      
    
     </header>
     
     <hr>
     
     <section data-title="intro">
     
      <textarea name="column_intro">{column_intro}</textarea></p>
    
     </section>
     
     <hr>
     
     <section data-title="content">
     
      <textarea name="column_content">{column_content}</textarea></p>
    
     </section>
     
     <section class="matrix-holder" data-title="footnotes">
     
      {field:column_footnotes}
    
     </section>
     
     <section class="matrix-holder" data-title="translations">
     
      {field:column_translations}
    
     </section>
     
     <hr>
     
     <section data-title="author notes">
     
      <textarea name="column_notes">{column_notes}</textarea></p>
    
     </section>
     
     <input type="submit" value="Submit" /></p>
      
    </div>
    
    {jquery-and-scripts}
    
    {safecracker_head}
     
    {/exp:safecracker}
    
    {/exp:channel:entries}

    I’ve also attached a screenshot.

    The “intro” field and the “content” field are the same type of custom field (just a plain textarea), but “intro” has text formatting set to None, and the “content” has formatting set to XHTML.

  • #4 / Oct 04, 2012 11:02am

    Shane Eckert

    7174 posts

    Hey Tim,

    Is there a reason you are enclosing the safecracker form in a channel entries tag pair?

    What version of ExpressionEngine are you currently running?

    Cheers,

  • #5 / Oct 04, 2012 11:09am

    Tim Murtaugh

    52 posts

    EE version: v2.5.2

    I pared back my code sample, but I have the entries tag in there so I can do this:

    {exp:channel:entries channel="columns" url_title="{segment_3}" limit="1" disable="categories|category_fields|member_data"}
    
    {if group_id == "1" OR member_id == author_id}

    Is there a better way to do that?

  • #6 / Oct 05, 2012 1:50pm

    Shane Eckert

    7174 posts

    Hi Tim,

    Yes there is! Give {if member_group == 'X'} a try. It’s a global variable so it operates outside of the channel entries tag.

    And just in case we are on the trail of a bug, can you update to 2.5.3?

    Thanks Tim!

    Cheers,

  • #7 / Oct 05, 2012 2:46pm

    Tim Murtaugh

    52 posts

    Thanks, I’ve updated to 2.5.3 and I’m still seeing P tags.

    W/r/t the member_group variable — that doesn’t seem to give me the “is this the entry author” logic I need.

  • #8 / Oct 08, 2012 12:40pm

    Shane Eckert

    7174 posts

    Hi Tim,

    Right, you can also use if member_id. If you take a look at the page I linked to above and here, there are several options to use to craft the logic you need.

    Can you try that?

    Does taking the SC form out of the Channel Entries loop get rid of the behavior for you?

    Thank you,,

  • #9 / Oct 08, 2012 12:48pm

    Tim Murtaugh

    52 posts

    Removing the entries loop does in fact get rid of the P tags, thanks.

    I’m sure I can figure out the other logic.

    Thanks!

  • #10 / Oct 09, 2012 11:27am

    Shane Eckert

    7174 posts

    Hi Tim,

    Sounds good! Glad you are able to move on. SC is particular about doing it’s own thing, does not like to be wrapped in a channel entries tag for sure.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases