Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change value of input field on another field's blur event in Strapi

I've been struggling with the docs of strapi for this.

There's a collection of articles. When creating an article, there are 2 fields i.e Start Date and End Date. Now when a value of Start Date changes and user is done selecting an event, I want to update the value of End Date 6 months from that.

Ofcourse the calculations of value are not a problem but I'm unable to find anything to update the value on blur event.

Right now, I'm using beforeCreate and beforeUpdate lifecycle hooks but all these hooks mentioned in strapi doc run when a user clicks Save button.

This might solve the case but this is not an idea scenario for a user coming from Wordpress or any other custom CMS where this is easily doable

like image 458
Muhammad Osama Avatar asked Oct 19 '25 12:10

Muhammad Osama


1 Answers

Strapi is not providing any blur events for now . We have Posted Comments on the strapi forum untill then only way to fix this is by using life cycle events provided by strapi. Refer this link https://docs.strapi.io/developer-docs/latest/development/backend-customization/models.html#lifecycle-hooks

  1. Get Date and Time in Separate Fields .
  2. Merge those values when clicking on save button .

https://forum.strapi.io/t/change-value-of-input-field-on-another-fields-blur-event-in-strapi/19829

like image 165
Naveen Jothi Avatar answered Oct 21 '25 01:10

Naveen Jothi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!