Add plain text SDT type
This commit is contained in:
parent
56ca30ab95
commit
a5ec49d99d
|
|
@ -90,7 +90,7 @@ class SDT extends Text
|
|||
*/
|
||||
public function setType($value)
|
||||
{
|
||||
$enum = array('comboBox', 'dropDownList', 'date');
|
||||
$enum = array('plainText', 'comboBox', 'dropDownList', 'date');
|
||||
$this->type = $this->setEnumVal($value, $enum, 'comboBox');
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,18 @@ class SDT extends Text
|
|||
$this->endElementP(); // w:p
|
||||
}
|
||||
|
||||
/**
|
||||
* Write text.
|
||||
*
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtText.html
|
||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
||||
* @param \PhpOffice\PhpWord\Element\SDT $element
|
||||
*/
|
||||
private function writePlainText(XMLWriter $xmlWriter, SDTElement $element)
|
||||
{
|
||||
$xmlWriter->startElement("w:text");
|
||||
$xmlWriter->endElement(); // w:{$type}
|
||||
}
|
||||
/**
|
||||
* Write combo box.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Reference in New Issue