Forums

Submit article: how to line break / paragraph

ms_buggy 30 Jun, 2011
Hello, thank you for the excellent tool, works like a charm.

But as I said on the topic, I need to use paragraphs in the articles. Written line breaks (enter) are stripped off when I submit a form as article.
Do you have any solution for this?

Kind regards,
Miss Buggy
GreyHead 30 Jun, 2011
Hi Miss Buggy,

I just ran a check and ChronoForms preserves the line breaks and they are saved in the database. The problem is that they are just lien breaks not HTML tags and Joomla! ignores them.

It might be possible to work roudn this with a bit more coding but it's probably simpler to use a rich text editor box to create the article text.

Bob
ms_buggy 01 Jul, 2011
Thanks!
Nice workaround would be to use php string nl2br function for the input field value before inserting it into database. But I cannot figure out what would be the place for this.
Can you advice me?
GreyHead 01 Jul, 2011
Hi ms_buggy,

I hacked the code and tried it but it didn't seem to make any visible difference :-(

More work is needed.

Bob
ms_buggy 01 Jul, 2011
? You hacked it to write <br> tags to database? That should work, because "manually" adding br-tags to input works fine. (manually really is not solution for this..)

This would be so great to have, of course I can use joomlas own 'new article form' function, but that is too complicated for my purposes.
GreyHead 02 Jul, 2011
Hi ms_buggy,

No I hacked the core code to run nl2br() on the submitted data. But it didn't add any <br /> codes for some reason. I'll try again using a Custom Code element.

Bob
GreyHead 02 Jul, 2011
Hi ms_buggy,

OK - that seems to work.

Add a Custom Code action in the OnSubmit event before the Submit Article action and put this code in it
<?php
$form->data['input_textarea_0'] = nl2br($form->data['input_textarea_0']);
?>
replacing input_texarea_0 with the name of your textarea. Repeat the code to apply to more than one textarea.

Bob
ms_buggy 04 Jul, 2011
Nice!
Thank you!
This topic is locked and no more replies can be posted.