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


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:

    '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

    And here’s a link to view the live example:

    Thanks in advance.

  • 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?


  • 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..

  • 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.


  • 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:

  • 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?


  • 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?

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


  • I’m getting this too, did you find the answer?

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

The topic ‘How to save html from textarea field using acf_form’ is closed to new replies.