Format LMT as Bulleted List in RTE

Take a comma-delimited value (like that from a Multi Select field) and convert it into a bulleted list when it is populated into a Rich-Text-Editor-enabled Paragraph Text field via its Live Merge Tag.

Code

Filename: gppa-format-lmt-as-bulleted-list.php

<?php
/**
 * Gravity Perks // Populate Anything // Format LMT as Bulleted List in RTE
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * Take a comma-delimited value (like that from a Multi Select field) and convert it into a bulleted list when it is
 * populated into a Rich-Text-Editor-enabled Paragraph Text field via its Live Merge Tag.
 */
// Update "123" with your form ID and "4" with your Checkbox field ID.
add_filter( 'gppa_live_merge_tag_value_123_4', function( $value, $merge_tag, $form, $field_id, $entry_values ) {

	$values = array_map( 'trim', explode( ',', $value ) );
	if ( empty( $values ) ) {
		return $value;
	}

	return sprintf( '<ul><li>%s</li></ul>', implode( '</li><li>', $values ) );
}, 10, 5 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.