FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API Refill Form Fields PROBLEM! \r\n
#1
Exclamation 
Hi

I have a big problem so I'll be as thorough as I can with my explanation.

I have a multi page form (3 pages) First page all text boxes, Second page mainly text areas, Third page shows all information entered in the First and Second pages for the customer to review.

If they need to go back and change anything there is a button linking back to the First or Second page so they can change a field then resubmit. Once happy they can send and finalize from the third page which goes to the thanks page.

So far so good and working, almost. In the Third page (review page) the details entered in all of the textareas which have had carriage returns used shows the horrible \r\n characters instead! this is the code used to display the session data from one of those text areas - Key Services (this is just to display the info for review its not an editable field)

Code:
<div class="spacer"><span>Key Services</strong></span><br>
                    <span class="lightgray"><?=@$fields["key_services"]?></span></div>

When I go back to the Second page to edit the info the same \r\n characters are displayed in the text area input field as well, the code for the field - Key Services

Code:
<textarea class="spacersml span12" rows="8" name="key_services" placeholder="Key Features and Services Details Here…"><?=@$fields["key_services"]?></textarea>

Points worth noting: If I fill in the form through to the third page (review page) and go into the database the un-finalized data shows in the database as it should, line breaks between paragraphs or anywhere where the return key has been used. If I go back and edit the second page where it is now displaying the \r\n characters and resubmit the page without removing the \r\n characters they will now be shown in the database as if they had been typed in, each time this is done extra \ seem to appear as well.

Also worth pointing out, if filling out the page and it is submitted without a required field the server side validation lists whats needed, refilling the completed fields correctly, the problem only occurs once the form is filled in correctly and moves on to the next page.

Being a beginner to PHP (I'm trying to learn) I may be missing something very simple but I have followed all of the tutorials to create a multi page form.

Its as if the data is being sent to the database correctly but when it is needed to be displayed again in the form pages it goes wrong.

Please help as I need to crack this, I've spent hours and hours day and night trying to solve it.

PS. I really love form tools.

Many many thanks
Steven
Reply
#2
This one stumped me for quite a bit. Here's what worked for me.

I had the single page form, and then instead of submitting right away, the user clicks a "continue" button to review their submission on the next page before hitting a "submit" button.

On the form:

Code:
<textarea name="abstract_body" id="abstract_body"><?=stripslashes(str_replace('\r\n', "\n", $fields["abstract_body"]))?></textarea>

On the review page:

Code:
<?=str_ireplace('\r\n','<br>',@$fields['abstract_body'])?>

Really hope this helps! Drove me nuts for a good while.


(Feb 7th, 2013, 3:00 AM)stenew Wrote: Hi

I have a big problem so I'll be as thorough as I can with my explanation.

I have a multi page form (3 pages) First page all text boxes, Second page mainly text areas, Third page shows all information entered in the First and Second pages for the customer to review.

If they need to go back and change anything there is a button linking back to the First or Second page so they can change a field then resubmit. Once happy they can send and finalize from the third page which goes to the thanks page.

So far so good and working, almost. In the Third page (review page) the details entered in all of the textareas which have had carriage returns used shows the horrible \r\n characters instead! this is the code used to display the session data from one of those text areas - Key Services (this is just to display the info for review its not an editable field)

Code:
<div class="spacer"><span>Key Services</strong></span><br>
                    <span class="lightgray"><?=@$fields["key_services"]?></span></div>

When I go back to the Second page to edit the info the same \r\n characters are displayed in the text area input field as well, the code for the field - Key Services

Code:
<textarea class="spacersml span12" rows="8" name="key_services" placeholder="Key Features and Services Details Here…"><?=@$fields["key_services"]?></textarea>

Points worth noting: If I fill in the form through to the third page (review page) and go into the database the un-finalized data shows in the database as it should, line breaks between paragraphs or anywhere where the return key has been used. If I go back and edit the second page where it is now displaying the \r\n characters and resubmit the page without removing the \r\n characters they will now be shown in the database as if they had been typed in, each time this is done extra \ seem to appear as well.

Also worth pointing out, if filling out the page and it is submitted without a required field the server side validation lists whats needed, refilling the completed fields correctly, the problem only occurs once the form is filled in correctly and moves on to the next page.

Being a beginner to PHP (I'm trying to learn) I may be missing something very simple but I have followed all of the tutorials to create a multi page form.

Its as if the data is being sent to the database correctly but when it is needed to be displayed again in the form pages it goes wrong.

Please help as I need to crack this, I've spent hours and hours day and night trying to solve it.

PS. I really love form tools.

Many many thanks
Steven

Reply
#3
Hi Steven,

I am working on a similar issue of re-filling form fields from the database, not the session array variable, $fields. I don't have the exact solution for your needs, but you can try re-loading the data from the database fields, rather than from the session data.

It's important to keep in mind the difference between re-filling data from a session variable, $fields in this case, and data from the database. The DB data is not held in the $fields array after a session has been closed. So, you would need to re-query the DB and store it into the $fields array (or some other variable) for use in your script.

That's just my "two cents" worth of help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)