XperienceCommunity.DependingFieldComponents 2.0.0

dotnet add package XperienceCommunity.DependingFieldComponents --version 2.0.0
                    
NuGet\Install-Package XperienceCommunity.DependingFieldComponents -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XperienceCommunity.DependingFieldComponents" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XperienceCommunity.DependingFieldComponents" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="XperienceCommunity.DependingFieldComponents" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XperienceCommunity.DependingFieldComponents --version 2.0.0
                    
#r "nuget: XperienceCommunity.DependingFieldComponents, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XperienceCommunity.DependingFieldComponents@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XperienceCommunity.DependingFieldComponents&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=XperienceCommunity.DependingFieldComponents&version=2.0.0
                    
Install as a Cake Tool

Xperience Community: Depending field components

Nuget build

When editing content, often developers will want to hide a field's input based on the value of another field. For example, if an article might contain a link to an external site, there will be a checkbox called "Has external link." If the checkbox is not checked, the text input for the external link should be hidden.

This project adds custom form components to Xperience by Kentico which allows developers to configure depending field functionality directly in the UI or code. These form components can be used in content types and widget properties.

Library Version Matrix

Xperience Version Library Version
>= 29.1.0 >= 2.0.0

Components

The project currently contains the following input types with depending field functionality:

  • Text
  • Number
  • Checkbox
  • Dropdown
  • Date time
  • Radio group

Configuring depending fields in the administration

In the Content types application, create two fields in which the visibility of one field depends on another field's value:

Content type fields

For the dependent field, choose a form component from this project, e.g. "Text input with field dependency." You will see two new properties that can be configured for the field:

  • Depends on: The name of the field that determines this field's visibility
  • Expected value: The value of the depending field which will reveal this field

Enter the name of another field in the content type, such as "HasExternalLink" in the above example. When that field's value changes, the current field's visibility will be reevaluated. In the expected value field, enter the string representation of the value required for the field to be shown. For example, if the field depends on a boolean field, the string representation of a checked box is "True."

Content type fields

Configuring depending fields in code

⚠️ The following is redundant as the default visibility attribute VisibleIfEqualToAttribute already offers the same functionality. However this will remain documented in the event that additional functionality is added in the future.

To configure depending widget properties, decorate the depending property with a form component attribute added by this project such as TextInputDependsOnProperty. Set the DependsOn property to the name of another widget property, and Expected value to the string representation of the value that will reveal this property.

In the following example, the text input will appear only if the checkbox is checked:

[CheckBoxComponent(Label = "Has target" , Order = 2)]
public bool HasTarget { get; set; }

[TextInputDependsOnProperty(DependsOn = nameof(HasTarget), ExpectedValue = "True", Label = "Button target", Order = 3)]
public string ButtonTarget { get; set; }
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 229 12/2/2024