Hello, I tried to post this under another discussion thread but something failed during the posting process. As this may be useful to some, I allow myself to post it as a separate topic.
Hi,
thanks for your posts! It helped me in making user-fields visible/invisible (hidden).
I have a document template in which I would like to keep user-type fields hidden, as they are not evaluated yet (custom code evaluates and updates them). But after these are evaluated and updated with values, I would like to make them visible for printing etc.
Here is what I do (if this could help someone else). First, create them invisible. In my case I use setTextFields to replace simple-text when creating the field (but you could use setTextField similarly?):
$doc->setTextFields(
$paragraph, "create-it-here", 'variable',
name => "MYFIELD",
display => 'none' # CREATE IT AS HIDDEN
);
this creates(*) a field reference in the document as this:
<text:user-field-get style:data-style-name="" text:display="none" text:name="MYFIELD">create-it-her
+e</text:user-field-get>
(*)Note: all user-type variable fields must be declared prior to all of this with setUserFieldDeclaration!
Then, I process the data and update the fields with: userFieldValue(), then, I want to make these visible, so I get all fields references and set the 'display' attribute on these:
my @refs = $doc->getUserFieldReferences("MYFIELD");
foreach my $r (@refs){
$r->set_att('text:display', "value");
}
It worked for OODoc 2.125 just as I needed it! The document format is ODF (.odt).
Praise be to the Lord, God, my creator who is much more wiser than me :)
(I'm very new to this, so forgive me if I don't make sense!)