Jump to content

Paragraph formatting when submitting from front-end


gRegor
 Share

Recommended Posts

Hello,

I have built a form that allows authenticated members to submit articles through a front-end form. I was under the impression that 2 newlines would automatically be converted to paragraph elements, but I'm pretty sure that's incorrect as I re-acquaint myself with this aspect of PW.**

Then I was thinking there was a TinyMCE configuration to convert newlines to paragraphs. There is, but I'm pretty sure that applies only during entry into the textarea, not when the text data is first loaded into the TinyMCE textarea.

First, is there a built-in PW paragraph formatting function that I'm missing/forgetting?

If not, would the "preferred" method to achieve this be using TinyMCE on the front-end form, so newlines are converted to paragraphs before the form is submitted and the page fields are stored? If so, can someone point me to an example of using the PW API to include a TinyMCE field input?

Or would the preferred method be to process the raw input to convert newlines to paragraphs (through another module, or custom code) before saving the page fields?

I'm aware there is an Auto Paragraph TextFormatter module, but I believe that only applies when the data is output — not when the data is shown in backend.

Thanks for any assistance!

** I have confirmed that the newlines are stored in the database, so I've confirmed they're neither being removed nor converted.

Link to comment
Share on other sites

Currently, I have chosen to set up a module based on the Auto Paragraph module linked above, except it's a general-use module that I load on demand and pass the text into. It seems to work well.

I'd still appreciate feedback if there is an easier / preferred method for doing this, though. Thanks!

Link to comment
Share on other sites

You could add a hook to FieldtypeTextarea::wakepValue() that is when loaded from db before rendered.

Or convert it before you save with sleepValue().

Or in when youre processing the form and store it to a page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...