Skip to main content

Choice-Single

A dropdown field for selecting a single option from a predefined list. Useful for selecting statuses, or any single-choice options.

Screenshots

Field render in form:

field preview

Field render in field group:

field preview

Configuration

  • Settings:

    • Name: The label for the field.
    • Slug: The unique technical identifier.
    • Choices: List of selectable options for the field.
    • Default value: Default selected option for the field.
  • Validation:

    • Require: Determines if the field must be filled out.
  • Design:

    • Instructions: Text displayed alongside the field providing details about the data needed.
    • Width: The width of the field in the form.
    • Classes: Custom CSS classes for styling the field.
    • ID: Custom ID attribute for the field.
    • Text before: Additional text displayed before the field.
    • Text after: Additional text displayed after the field.

Return format

  • Type: string or null
  • Note: Return the key if defined.

Usage

/some-template.tpl
{* Object or Entity and Id *}
{assign var="data" value=$modules.customfieldgroups.data->get($product)}
{assign var="data" value=$modules.customfieldgroups.data->get('product', $product.id)}

{if $data.field_group_slug.field_slug eq "key"}
..
{/if}
/SomeClass.php
function someMethod()
{
$dataRetriever = DataRetrieverFacade::getInstance();

$data = $dataRetriever->get($object); // Object
$data = $dataRetriever->get('product', $idProduct); // Entity and id

$value = $data['field_group_slug']['field_slug'];
}