added functionality specified alias and tag

This commit is contained in:
sergeizelenyi 2017-01-23 16:15:33 +03:00
parent 6da9d8a0bf
commit 1ab93e7e8a
2 changed files with 50 additions and 0 deletions

View File

@ -45,6 +45,20 @@ class SDT extends Text
*/
private $listItems = array();
/**
* Alias
*
* @var string
*/
private $alias;
/**
* Tag
*
* @var string
*/
private $tag;
/**
* Create new instance
*
@ -127,4 +141,36 @@ class SDT extends Text
return $this;
}
/**
* @return string
*/
public function getTag()
{
return $this->tag;
}
/**
* @param string $tag
*/
public function setTag($tag)
{
$this->tag = $tag;
}
/**
* @return mixed
*/
public function getAlias()
{
return $this->alias;
}
/**
* @param mixed $alias
*/
public function setAlias($alias)
{
$this->alias = $alias;
}
}

View File

@ -43,6 +43,8 @@ class SDT extends Text
}
$type = $element->getType();
$writeFormField = "write{$type}";
$alias = $element->getAlias();
$tag = $element->getTag();
$this->startElementP();
@ -50,6 +52,8 @@ class SDT extends Text
// Properties
$xmlWriter->startElement('w:sdtPr');
$xmlWriter->writeElementBlock('w:alias', 'w:val', $alias);
$xmlWriter->writeElementBlock('w:tag', 'w:val', $tag);
$xmlWriter->writeElementBlock('w:id', 'w:val', rand(100000000, 999999999));
$xmlWriter->writeElementBlock('w:lock', 'w:val', 'sdtLocked');
$this->$writeFormField($xmlWriter, $element);