Support

Account

Home Forums Feedback Basic textfield with simple formatting options (bold, italic, links, …)

Solving

Basic textfield with simple formatting options (bold, italic, links, …)

  • Been using ACF pretty much since the beginning, but I have always wondered why we can’t create simple, one line textfields and add basic formatting options to them like bold, italic, or links.

    I want to keep the admin as clean, simple, and clutter free as possible. But being able to add italic to text without having to write it in HTML is important to many clients. That being said, when these options become necessary for a very simple field, something in which a single word, or a simple phrase will be entered, having to transform that textfield into a WYSIWIG content editor creates a lot of clutter on the admin.

    Having the option to determine what basic options are (I’m thinking mainly bold, italic and links, options adapted to one-line text inputs) to the basic textfield would be an incredible addition!

    • James

    • September 15, 2016 at 1:30 pm

    Hi @brunocloutier

    For this case, you need to create a function that will convert certain patterns to certain HTML tags. You can use the preg_replace() function to do it. For example, if you want to convert the words between stars (*) into italic, you can use this code:

    $text = get_field('text');
    $pattern = '/(.*)\*(.*)\*(.*)/';
    $replacement = '$1<i>$2</i>$3';
    echo preg_replace($pattern, $replacement, $text);

    That way you can input the text like this:

    this is normal *this is italic* this is normal

    I hope this helps 🙂

  • Hi James,

    That’s one way to implement it. I was thinking about something more visual, more suitable for less tech savy users, but I’ll keep your idea in mind!

  • I just found this, maybe you should give the author of this plugin some input https://github.com/lukechapman/acf-inline-wysiwyg

  • Oh, that looks super interesting! I’ll definetely take a look.

  • I would like to have the option for a single line text field with basic styling too. For now I’ll use the acf-medium-editor plugin. Would be nice to see this integrated in ACF or ACF Pro.

Viewing 6 posts - 1 through 6 (of 6 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.