Support

Account

Home Forums ACF PRO How to save html from textarea field using acf_form

Solving

How to save html from textarea field using acf_form

  • Hi,

    What I’m trying to do is create a field that where you can edit plain text and HTML and see your HTML work as you go, you will also have the ability to save your work and get a link to your post.

    I got everything figured out beside the fact that textarea field for some reason can’t save html, if you delete the html code and just write plain text it works and redirect you to the new post you have created.

    but as long as you have < tag or > tag the page will not be saved and a new post will not be created.

    you can see that when it works you are redirected to a post template which is not ready yet.

    Here’s my php code:

    <?php
    acf_form(array(
    'post_id'       => 'new_post',
    'new_post'      => array( 'post_status'     => 'publish' ),
    'submit_value'  => 'Save',
    'post_content'  => false,
    'form_attributes' => array( 'name'      => 'f' ),
    'fields' => array( 'field_56fe0df2db85a' ),
    'return' => '%post_url%',
    'updated_message' => __("", 'acf')
    ));
    ?>

    I’m running ACF PRO Version 5.3.6.1

    And here’s a link to view the live example: http://html.magme.net/

    Thanks in advance.

    • James

    • April 4, 2016 at 2:51 pm

    Hi @rmoses123

    I’ve just tested it using ACF’s default front end form and it could save the HTML tag as expected. It’s possible that your saving function is the one that prevents it. Could you please share the saving code?

    Thanks!

  • What saving code? I didn’t know there was a code I needed for saving the data.

    I figured it works like custom field on a template where the form is just moving the field to the front end.

    What I have now is only a template for the front page with the code I posted,
    Was I suppose to do something more in order for it to save?

    It is working for plain text as it is tough..

    • James

    • April 4, 2016 at 4:33 pm

    Hi @rmoses123

    I’m sorry I thought you used a custom code to save it. I’ve just tested your code and it was working as it should be. It’s possible that there’s a conflict with your theme or plugins. Could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Fifteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.

    Thanks!

  • I’ve tried moving the front-page.php as it is to twenty twelve and deactivated all plugins (I only use ACF & Yoast SEO which is now inactive).

    I am having the same problem, when writing anything using < or > the page just refreshes and if plain text is there then it redirects to the new post url.

    You can see in it here: http://html.magme.net/

    • James

    • April 6, 2016 at 4:15 pm

    Hi @rmoses123

    Another possibility I can think of is that your server has a setup that prevents the HTML tags for being posted. Could you please create a local installation on your computer to test that code?

    Also, could you please share the JSON export of the field group and the customized theme so I can test it out in my installation?

    Thanks!

    • jkjkjk

    • May 23, 2019 at 12:04 am

    Hi, i got the same problem.
    no matter which acf field i use (textarea or wysiwyg editor) in the field group, all the postet html tags (for example an iframe) gets deleted when i save the page.
    that’s only happening on my server setup not on my localhost.

    can you tell me what i need to change on my server?

    • glogan

    • June 14, 2019 at 7:12 am

    I have the same issue. I’ve tagged this thread, hoping for a response.

    TIA.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.