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

[5.x]: Required property not set on custom field object #15752

Open
peteeveleigh opened this issue Sep 18, 2024 · 1 comment
Open

[5.x]: Required property not set on custom field object #15752

peteeveleigh opened this issue Sep 18, 2024 · 1 comment
Assignees
Labels

Comments

@peteeveleigh
Copy link

What happened?

Description

When looping through custom fields I was trying to automatically set the required attribute based on {{ customField.required }}. It looks like this property has been moved into {{ customField.layoutElement.required }} but the original property still exists and is not being set - it's always false.

Custom field properties. The required property is false, despite the field being set to 'required'
Screenshot 2024-09-18 at 09 45 59

Same field, layoutElement
Screenshot 2024-09-18 at 10 05 14

While I understand that this property has been moved into layoutElement, if the original property remains then should it also honour the required setting of the field for consistency's sake. At least until fully deprecated (if that's the plan) .

Steps to reproduce

  1. Create a custom field and set it to be required
  2. On the front-end loop through the custom fields and use the {{ customField.required }} property to set the required attribute on the field.

Expected behavior

The field should received a required attribute

Actual behavior

The {{ customField.required }} property is always false while the {{ customField.layoutElement.required }} property honours the setting in the CP.

Craft CMS version

5.4.4

PHP version

8.2.18

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@i-just
Copy link
Contributor

i-just commented Sep 19, 2024

Hi, thanks for reporting. I raised a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants