0

I wrote a simple fieldtype that checks that the field value is unique for a specific entry type: https://github.com/fuel-digital/Craft-Unique-Text-FieldType

This worked fine initially but after the recent core updates, $this->element in the valueExists() method is null on new entries, where previously it was an instance of ElementType::Entry or whatever else the field was attached to.

While I could instantiate a new ElementType::Entry object if one doesn't exist, this limits the field's use to Entries, and not Assets, Users etc.

Is there some other way of getting the element's value now? I can't see anything when inspecting the field class.

2
  • $this->element won't necessarily be set depending on the context your field type is used in, so your field type needs to be aware of that. That's always been the case, too, so I doubt a recent update changed anything related to that. – Brad Bell Jan 6 '15 at 19:32
  • Weird, as it was fine in testing until recently. Any suggestions on how I can achieve what I'm looking to do? – Russ Back Jan 6 '15 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.