Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ v0.16.0 (xx dec 2018)
- Add ability to pass a Style object in Section constructor @ndench #1416
- Add support for hidden text @Alexmg86 #1527
- Add support for setting images in TemplateProcessor @SailorMax #1170
- Add "Plain Text" type to SDT (Structured Document Tags) @morrisdj #1541

### Fixed
- Fix regex in `cloneBlock` function @nicoder #1269
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Element/SDT.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function getType()
*/
public function setType($value)
{
$enum = array('comboBox', 'dropDownList', 'date');
$enum = array('plainText', 'comboBox', 'dropDownList', 'date');
$this->type = $this->setEnumVal($value, $enum, 'comboBox');

return $this;
Expand Down
12 changes: 12 additions & 0 deletions src/PhpWord/Writer/Word2007/Element/SDT.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ public function write()
$this->endElementP(); // w:p
}

/**
* Write text.
*
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtText.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
*/
private function writePlainText(XMLWriter $xmlWriter)
{
$xmlWriter->startElement('w:text');
$xmlWriter->endElement(); // w:text
}

/**
* Write combo box.
*
Expand Down
4 changes: 2 additions & 2 deletions tests/PhpWord/Element/SDTTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class SDTTest extends \PHPUnit\Framework\TestCase
*/
public function testConstruct()
{
$types = array('comboBox', 'dropDownList', 'date');
$type = $types[rand(0, 2)];
$types = array('plainText', 'comboBox', 'dropDownList', 'date');
$type = $types[rand(0, 3)];
$value = rand(0, 100);
$alias = 'alias';
$tag = 'my_tag';
Expand Down
3 changes: 3 additions & 0 deletions tests/PhpWord/Writer/Word2007/ElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ public function testSDTElements()
$section->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'))->setValue('select value');
$section->addSDT('dropDownList');
$section->addSDT('date')->setAlias('date_alias')->setTag('my_tag');
$section->addSDT('plainText');

$doc = TestHelperDOCX::getDocument($phpWord);

Expand All @@ -405,6 +406,8 @@ public function testSDTElements()
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:date'));
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:alias'));
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:tag'));

$this->assertTrue($doc->elementExists($path . '[4]/w:sdt/w:sdtPr/w:text'));
}

/**
Expand Down