Forum


Replies: 1   Views: 1614
List not working when inside an array of word fragments
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by dannyguest  · 28-05-2020 - 14:53

Afternoon,

I am trying to achieve something like this: 

Test -> AddText WF

  • Foo -> AddList WF
  • Foo
  • Foo​

Test2

  • Foo
  • Foo

 

$event_wf = new WordFragment($phpdocx, 'document');
        $paragraphOptions = array(
            'lineBreak' => 'after',
            'bold' => 'true',
        );
        $itemList = array(
            'Line 1',
            'Line 2',
            'Line 3',
            'Line 4',
            'Line 5'
        );
        foreach ($events as $key => $value) {
            $wf = new WordFragment($phpdocx, 'document');
            $wf->addText($value->AccordianLabel, $paragraphOptions);
            $events_array[] = $wf;

            $wf_bullets = new WordFragment($phpdocx, 'document');
            $wf_bullets->addList($itemList, 1);
            $events_array[] = $wf_bullets;
        }

        $event_wf->addText($events_array);
        
        $phpdocx->replaceVariableByWordFragment(array('DATA_EVENTS' => $event_wf));

The problem is my output is like this: 

Test
FOOFOOFOOTest2
FOOFOO

So the list isn't working. Any ideas?

Thanks in advance