Paragraph field and processing each line as new data

I’m planning to use a paragraph field to allow users to enter codes. There could be up to 200 lines and each code will be on its own line.

My plan is to then take each code and input it into a table to be referenced later.

Is there a way to easily process each line in a paragraph field and break it out?

When are you planning on storing the data in another table? Is that going to be done right after the form is submitted? If so, you can use the gform_after_submission filter:

As for how to split that input, I recommend using the built in logging in Gravity Forms:

Just log the $entry after submission to see what the data looks like, then split it up and insert into your other table using PHP:

add_action( 'gform_after_submission', 'split_the_paragraph', 10, 2 );
function split_the_paragraph( $entry, $form ) {
	GFCommon::log_debug( __METHOD__ . '(): The Entry => ' . print_r( $entry, true ) );

I was going to try and split up that paragraph text, line by line, but I can’t seem to find how how to actually get the value of whats in the paragraph text field. Can you point me in the right direction that?

Then I guess I can split base on new lines and put each line as an entry in a table. (The form is loading coupon codes, one per line).

I posted previously how to log the submission/entry. When you do that, you can check the log to see what the data looks like, then use your own PHP to split the paragraph. Have you implemented the previous suggestion? If so, can you test the form and post the link to the log file (this is a public forum, so be sure the log contains only your test submission.)

I did. I actually sent the link to the log file and had some questions. Not sure if the email made it to you then. I’ll check in the morning when I’m back at the office.

I don’t have your email. Please send it to - thank you.

Hi Jeff. I just realized you opened a support ticket too. I am going to close this and concentrate on the support ticket. Thank you.

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.