Skip to content

Commit 9ac9016

Browse files
sergeizelenyitroosan
authored andcommitted
added functionality specified alias and tag
1 parent a7a35c6 commit 9ac9016

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
*
@@ -126,4 +140,36 @@ public function setListItems($value)
126140

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

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ public function write()
4141
}
4242
$type = $element->getType();
4343
$writeFormField = "write{$type}";
44+
$alias = $element->getAlias();
45+
$tag = $element->getTag();
4446

4547
$this->startElementP();
4648

4749
$xmlWriter->startElement('w:sdt');
4850

4951
// Properties
5052
$xmlWriter->startElement('w:sdtPr');
53+
$xmlWriter->writeElementBlock('w:alias', 'w:val', $alias);
54+
$xmlWriter->writeElementBlock('w:tag', 'w:val', $tag);
5155
$xmlWriter->writeElementBlock('w:id', 'w:val', rand(100000000, 999999999));
5256
$xmlWriter->writeElementBlock('w:lock', 'w:val', 'sdtLocked');
5357
$this->$writeFormField($xmlWriter, $element);

0 commit comments

Comments
 (0)