DynaPDF.SetFieldFlags
---------------------

The function sets the flags of a specific interactive form field.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [4.0](newinversion40.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.SetFieldFlags"; PDF; Field; Flags; Reset ) 

**MBS**( **"DynaPDF.SetFieldFlags";** /\* The function sets the flags of a specific interactive form field. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Field**; /\* The field index or field name.e.g. "FirstName" \*/   
**$Flags**; /\* New field flags. You can pass a flag by namee.g. 1 \*/   
**$Reset**) /\* Pass 1 to set flags to the ones you passed or pass 0 to add the flag.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Field | The field index or field name. | "FirstName" |
| Flags | New field flags. You can pass a flag by name | 1 |
| Reset | Pass 1 to set flags to the ones you passed or pass 0 to add the flag. | 1 |

### Result

Returns OK or error.

### Description

The function sets the flags of a specific interactive form field.   
The parameter Flags is a bit mask, multiple flags can be set by adding the values or use a bitwise Or operator, e.g. Print + Multiline (4096+32 = 4128). If the parameter Reset is 1 the flags of the field are set to the ones specified. If Reset is 0, the flags are added by using a bitwise Or operator.  
  
Possible flag names: ReadOnly, Required, NoExport, Invisible, Hidden, Print, NoZoom, NoRotate, NoView, Multiline, Password, NoToggleToOff, RadioIsUnion, CommitOnSelCh, Edit, Sorted, FileSelect, MultiSelect, DoNotSpellCheck, DoNotScroll or Comb.  
See Dynapdf\_help.pdf for the meaning of the flags or their numerical value.  
  
Instead of making a field read only, you can also flatten it with [DynaPDF.FlattenAnnotOrField](DynaPDFFlattenAnnotOrField.md) function.  
See also [SetFieldFlags](https://www.monkeybreadsoftware.com/DynaPDF-Manual/SetFieldFlags.shtml) function in DynaPDF manual.

### Examples

Create a read only invisible field to e.g. hide your record ID in FileMaker:

 Set Variable \[ $r ; Value:  
Let ( \[   
fieldName = "ID";   
field = MBS ( "[DynaPDF.CreateTextField](DynaPDFCreateTextField.md)"; $pdf ; fieldName; -1; 0; 200; 120; -50; 300; 20 );   
r = MBS ("DynaPDF.SetFieldFlags"; $pdf ; field; "Hidden ReadOnly Invisible NoView"; 0)   
/\* yes, three ways to hide! \*/   
\]; field ) \]  
Create readonly field:

 Set Variable \[ $r ; Value:  
Let ( \[   
 fieldName = "Customer No";   
 field = MBS ( "[DynaPDF.CreateTextField](DynaPDFCreateTextField.md)"; $pdf ; fieldName; -1; 0; 200; 120; -50; 300; 20 );   
 r = MBS ("DynaPDF.SetFieldFlags"; $pdf ; field; "ReadOnly"; 0)   
\]; field ) \]  
Loop over all fields and turn them read only:

 Set Variable \[ $count ; Value: MBS ( "[DynaPDF.GetFieldCount](DynaPDFGetFieldCount.md)"; $PDF ) \]   
Set Variable \[ $index ; Value: 0 \]   
If \[ $index ≤ $count \]   
 Loop \[ Flush: Always \]  
 # turn field to read only  
 Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFieldFlags"; $pdf ; $index ; "ReadOnly"; 0 ) \]   
 #   
 # next  
 Set Variable \[ $index ; Value: $index + 1 \]   
 Exit Loop If \[ $index ≥ $count \]   
 End Loop  
End If  
### See also

- [DynaPDF.GetField](DynaPDFGetField.md)
- [DynaPDF.GetFieldCount](DynaPDFGetFieldCount.md)
- [DynaPDF.GetFieldFlags](DynaPDFGetFieldFlags.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetFieldDate](DynaPDFSetFieldDate.md)
- [DynaPDF.SetFieldFont](DynaPDFSetFieldFont.md)
- [DynaPDF.SetFieldMapName](DynaPDFSetFieldMapName.md)
- [DynaPDF.SetFieldName](DynaPDFSetFieldName.md)
- [DynaPDF.SetGStateFlags](DynaPDFSetGStateFlags.md)
- [DynaPDF.SetImportFlags](DynaPDFSetImportFlags.md)

### Example Databases

- [DynaPDF/Create PDF with sum form field](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Create%20PDF%20with%20sum%20form%20field.shtml#2ScriptAnchor_)
- [DynaPDF/Form/Form](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Form/Form.shtml#3ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 6 - Sending Out Wishlist Forms](https://www.mbsplugins.de/archive/2024-12-06/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [PDF Forms with MBS Plugin](https://www.mbsplugins.de/archive/2018-04-21/PDF_Forms_with_MBS_Plugin/monkeybreadsoftware_blog_filemaker)
- [Tip of the day: DynaPDF form creation with calculation with FileMaker](https://www.mbsplugins.de/archive/2016-08-24/Tip_of_the_day_DynaPDF_form_cr/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2022, Seite 19](https://filemaker-magazin.de/neuigkeit/4172-Appetithappen-FMM_202201)

This function checks for a license.

Created 18th August 2014 , last changed 15th December 2023

  
[DynaPDF.SetFieldExpValueEx](DynaPDFSetFieldExpValueEx.md) - [DynaPDF.SetFieldFont](DynaPDFSetFieldFont.md)

[HTML Version](DynaPDFSetFieldFlags.shtml)