# Collection events on the admin side for edit/udpate view pages

**URL:** <https://discourse.getcockpit.com/t/collection-events-on-the-admin-side-for-edit-udpate-view-pages/194>\
**Category:** Support\
**Created:** [August 7, 2018, 11:44pm UTC](https://discourse.getcockpit.com/t/collection-events-on-the-admin-side-for-edit-udpate-view-pages/194 "2018-08-07T23:44:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![owldesign](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/owldesign/32/66_2.png) [@owldesign](https://discourse.getcockpit.com/u/owldesign)\
**Post date:** [August 7, 2018, 11:44pm UTC](https://discourse.getcockpit.com/t/collection-events-on-the-admin-side-for-edit-udpate-view-pages/194/1 "2018-08-07T23:44:48Z")

</div>

Hey guys I’m wondering if anyone can suggest a workaround for my issue.

I have created a new Addon for fieldtype called “Encrypt” so its just a plain text field that will encrypt value when saving to database and decrypt when retrieving.

I can get the decrypted value while previewing list of entries in the admin and via rest api. However, I cannot seem to figure out how to decrypt it while in the update/edit page of the entry. I get the ecrypted value in the input area.

Right now I’m hardcoing an event within `modules/Collections/Controller/Admin.php` around line `175` with this `$this->app->trigger("collections.admin.entry", [&$entry]);`. This way I can catch the entry before showing and decrypt the values for my fieldtypes.

I guess my question is anyone know if there is a way to hook into the `entry` to update values before its rendered to the view? Is there something I can do within the `.tag` file for my `field-encrypt.tag`?

Let me know if this makes sense? Thanks!!!

---

<div class="post-metadata">

**Author:** ![pauloamgomes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pauloamgomes/32/48_2.png) [@pauloamgomes](https://discourse.getcockpit.com/u/pauloamgomes)\
**Post date:** [August 8, 2018, 8:36am UTC](https://discourse.getcockpit.com/t/collection-events-on-the-admin-side-for-edit-udpate-view-pages/194/2 "2018-08-08T08:36:51Z")

</div>

Hey @owldesign, yes, I think you need to do it inside your field-encrypt.tag, maybe something like:

```
this.$updateValue = function(value, field) {
  this.value = your_decrypt_function(value);
  this.update();
}.bind(this);
```

---

<div class="post-metadata">

**Author:** ![owldesign](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/owldesign/32/66_2.png) [@owldesign](https://discourse.getcockpit.com/u/owldesign)\
**Post date:** [August 8, 2018, 3:45pm UTC](https://discourse.getcockpit.com/t/collection-events-on-the-admin-side-for-edit-udpate-view-pages/194/3 "2018-08-08T15:45:12Z")

</div>

@pauloamgomes how would I make a call to php method within that? Would I have to make a GET/POST request?

Edit: Ok I figured it out now. I created a Controller class with methods. And from my `tag` file I do a `$.get` reqeuest to my controller method to decrypt the value.

I’ll post the encryption field addon once I test/clean it up. Thanks for the help!

Edit 2: I published my addon on github. Maybe someone can give it a test drive [https://github.com/owldesign/Encrypt](https://github.com/owldesign/Encrypt) its my first addon and just few days digging around Cockpit so I’d appreciate any feedback on what I’m doing wrong. Thanks!!

---

<div class="post-metadata">

**Author:** ![pauloamgomes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pauloamgomes/32/48_2.png) [@pauloamgomes](https://discourse.getcockpit.com/u/pauloamgomes)\
**Post date:** [August 8, 2018, 8:51pm UTC](https://discourse.getcockpit.com/t/collection-events-on-the-admin-side-for-edit-udpate-view-pages/194/4 "2018-08-08T20:51:28Z")

</div>

Nice work @owldesign, will look in more detail, but probably you should put the vendor folder in .gitignore
