Skip to content

Ability to use field AUTHOR - Word #2810

@dregini

Description

@dregini

Describe the problem

I think it would be useful to add something like

$header->addPreserveText("{AUTHOR}");
or
$header->addField('AUTHOR')

this way the field will auto adapt if the user change the author of the word file

Describe the expected behavior

i tried to edit the PhpWord/Writer/Word2007/Element/Field.php:

    private function writeAuthor(ElementField $element): void
    {
        $xmlWriter = $this->getXmlWriter();
        $xmlWriter->startElement('w:fldSimple');
        $xmlWriter->writeAttribute('w:instr', 'AUTHOR');
        $xmlWriter->endElement(); // w:fldSimple  
}

and in PhpWord/element/Field.php:

protected $fieldsArray = [
       'AUTHOR' => [ ],
      ...
];

Priority

  • I want to crowdfund the feature (with @algora-io) and fund a community developer.
  • I want to pay the feature and fund a maintainer for that. (Contact @Progi1984)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions