user6666864
user6666864

Reputation:

Adding bullets to all items from a data variable

I am using Machform, which is a form creater / maker, for our forms. Unfortunately the developer has no interest anymore in offering support on questions. So I am wondering if someone on stackoverflow can provide some help.

I am using the following piece of code:

        if($form_id == 65822){
            if($data['element_id'] == 52){
                if(!empty($data['value'])){
                    $data['value'] = '<p>Example text:</p><ul style="color:#444444 !important;font-size:14px;list-style:square;"><li><a style="text-decoration:none !important;color:#444444 !important;" href="#">'.$data['value'].'</a></li></ul>';
                }
            }
        }

This works when there is a single item being displayed. The item gets a square (bullet) in front of the item.

However when there are more items, only the first item gets a square (bullet). The rest don't get a bullet.

It should, however, be displayed like this:

So everything which is being displayed should have a square (bullet) in front of it.

Is there an easy fix for this?

The $data['value'] variable is collected from the stuff entered in the form. In this case it's multi-text line / paragraph field.

Upvotes: 0

Views: 407

Answers (1)

GreensterRox
GreensterRox

Reputation: 7140

It would better to modify the area of code that collects the text that goes into $data['value']. Maybe create a new array variable $data['bullets'] and push each bullet to that individually:

$data['bullets'][] = "'<li><a style="text-decoration:none !important;color:#444444 !important;" href="#">First item</a></li>";
$data['bullets'][] = "'<li><a style="text-decoration:none !important;color:#444444 !important;" href="#">Second item"</a></li>;
$data['bullets'][] = "'<li><a style="text-decoration:none !important;color:#444444 !important;" href="#">Third item</a></li>";

if($form_id == 65822){
            if($data['element_id'] == 52){
                if(!empty($data['value'])){
                    $data['value'] = '<p>Example text:</p><ul style="color:#444444 !important;font-size:14px;list-style:square;">'.implode('',$data['bullets']).'</ul>';
                }
            }
        }

Upvotes: 1

Related Questions