Skip to content

Commit 1ab93e7

Browse files
committed
added functionality specified alias and tag
1 parent 6da9d8a commit 1ab93e7

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/PhpWord/Element/SDT.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ class SDT extends Text
4545
*/
4646
private $listItems = array();
4747

48+
/**
49+
* Alias
50+
*
51+
* @var string
52+
*/
53+
private $alias;
54+
55+
/**
56+
* Tag
57+
*
58+
* @var string
59+
*/
60+
private $tag;
61+
4862
/**
4963
* Create new instance
5064
*
@@ -127,4 +141,36 @@ public function setListItems($value)
127141

128142
return $this;
129143
}
144+
145+
/**
146+
* @return string
147+
*/
148+
public function getTag()
149+
{
150+
return $this->tag;
151+
}
152+
153+
/**
154+
* @param string $tag
155+
*/
156+
public function setTag($tag)
157+
{
158+
$this->tag = $tag;
159+
}
160+
161+
/**
162+
* @return mixed
163+
*/
164+
public function getAlias()
165+
{
166+
return $this->alias;
167+
}
168+
169+
/**
170+
* @param mixed $alias
171+
*/
172+
public function setAlias($alias)
173+
{
174+
$this->alias = $alias;
175+
}
130176
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ public function write()
4343
}
4444
$type = $element->getType();
4545
$writeFormField = "write{$type}";
46+
$alias = $element->getAlias();
47+
$tag = $element->getTag();
4648

4749
$this->startElementP();
4850

4951
$xmlWriter->startElement('w:sdt');
5052

5153
// Properties
5254
$xmlWriter->startElement('w:sdtPr');
55+
$xmlWriter->writeElementBlock('w:alias', 'w:val', $alias);
56+
$xmlWriter->writeElementBlock('w:tag', 'w:val', $tag);
5357
$xmlWriter->writeElementBlock('w:id', 'w:val', rand(100000000, 999999999));
5458
$xmlWriter->writeElementBlock('w:lock', 'w:val', 'sdtLocked');
5559
$this->$writeFormField($xmlWriter, $element);

0 commit comments

Comments
 (0)