How to decrypt using Encrypted Field TypeCreated 5 years ago by kiltedup
I have added a field using the Encrypted Field Type. All fine and can see it is indeed encrypted in db.
However when I come to decrypt, I'm getting this error :
"Call to a member function decrypt() on string"
The config is the default, so auto_decrypt is set to false - getting the error when using
$entry->thefield->decrypt() as per docs.
Anyway using this field type / seen this / have any tips?
OK - I see what is going on but not sure why?
I have a stream with around 15 fields - one of them is the encrypted field type. When the form is first submitted, all fields are entered and checking again, the decrypt is fine.
But I reuse the form again in a couple of places to edit the entry but just 2 of the fields (not the encrypted one) - they are set using
When that is submitted, the two fields are updated however the encryption is done again on the encrypted field. So my output that I thought was the encryption not working when using ->decorated, is in fact the decrypted value, except it is a decryption of the previous encrypted value !!!!!!!
My head hurts 😄
Is there a way to stop the encrypted field updating like this?
Aha! You want to
skip those fields. You can do
$builder->setSkips($fieldSlugs) or a combination of the two (The latter is dictative)
Fields is more about configuration overrides n such.. and simple placement sometimes when no layout.
I'll test on this end momentarily but check for slugs and if it's a multiform builder you'll need to skip it (including prefix) from the parent / muti builder OR without prefix from the child form.
decryptis a presenter method so you will need to do