Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional custom fields with showon #39051

Merged
merged 5 commits into from Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions administrator/components/com_fields/forms/field.xml
Expand Up @@ -246,6 +246,13 @@
<option value="">COM_FIELDS_FIELD_EDITABLE_IN_BOTH</option>
</field>

<field
name="showon"
type="text"
label="COM_FIELDS_FIELD_SHOWON_LABEL"
description="COM_FIELDS_FIELD_SHOWON_DESC"
/>

</fieldset>
<fieldset name="renderoptions" label="COM_FIELDS_FIELD_RENDEROPTIONS_HEADING">

Expand Down
Expand Up @@ -186,6 +186,11 @@ public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form
$node->setAttribute('hint', $field->params->get('hint', ''));
$node->setAttribute('required', $field->required ? 'true' : 'false');

$showon_attribute = $field->params->get('showon', '');
if ($showon_attribute) {
$node->setAttribute('showon', $showon_attribute);
}

if ($layout = $field->params->get('form_layout')) {
$node->setAttribute('layout', $layout);
}
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/com_fields.ini
Expand Up @@ -59,6 +59,8 @@ COM_FIELDS_FIELD_REQUIRED_LABEL="Required"
COM_FIELDS_FIELD_SAVE_SUCCESS="Field saved"
COM_FIELDS_FIELD_SHOWLABEL_DESC="Show or Hide the label when the field displays."
COM_FIELDS_FIELD_SHOWLABEL_LABEL="Label"
COM_FIELDS_FIELD_SHOWON_LABEL="Showon Attribute"
COM_FIELDS_FIELD_SHOWON_DESC="Conditionally show or hide the field depending on other field values"
obuisard marked this conversation as resolved.
Show resolved Hide resolved
COM_FIELDS_FIELD_SUFFIX_LABEL="Suffix"
COM_FIELDS_FIELD_TYPE_LABEL="Type"
COM_FIELDS_FIELD_USE_GLOBAL="Use settings from Plugin"
Expand Down