Skip to content

Commit a5ec49d

Browse files
committed
Add plain text SDT type
1 parent 56ca30a commit a5ec49d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/PhpWord/Element/SDT.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function getType()
9090
*/
9191
public function setType($value)
9292
{
93-
$enum = array('comboBox', 'dropDownList', 'date');
93+
$enum = array('plainText', 'comboBox', 'dropDownList', 'date');
9494
$this->type = $this->setEnumVal($value, $enum, 'comboBox');
9595

9696
return $this;

src/PhpWord/Writer/Word2007/Element/SDT.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ public function write()
7373
$this->endElementP(); // w:p
7474
}
7575

76+
/**
77+
* Write text.
78+
*
79+
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtText.html
80+
* @param \PhpOffice\Common\XMLWriter $xmlWriter
81+
* @param \PhpOffice\PhpWord\Element\SDT $element
82+
*/
83+
private function writePlainText(XMLWriter $xmlWriter, SDTElement $element)
84+
{
85+
$xmlWriter->startElement("w:text");
86+
$xmlWriter->endElement(); // w:{$type}
87+
}
7688
/**
7789
* Write combo box.
7890
*

tests/PhpWord/Element/SDTTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class SDTTest extends \PHPUnit\Framework\TestCase
2929
*/
3030
public function testConstruct()
3131
{
32-
$types = array('comboBox', 'dropDownList', 'date');
33-
$type = $types[rand(0, 2)];
32+
$types = array('plainText', 'comboBox', 'dropDownList', 'date');
33+
$type = $types[rand(0, 3)];
3434
$value = rand(0, 100);
3535
$alias = 'alias';
3636
$tag = 'my_tag';

0 commit comments

Comments
 (0)