groceryCrudSetFieldValue does not trigger depended-relation loading for dropdown fields

Hello,

I’m using groceryCrudSetFieldValue('country_id', '181') which works fine by itself. However because I have state_id, city_id with setDependentRelation It only fills the country_id value without triggering .trigger('change') the state_id to get the values.

Is there a way by using groceryCrudSetFieldValue to get same results as I would select the country in the browser ?

Regards

Hello @Anwar ,

I can reproduce your issue and there isn’t currently any work-around for this. I will try to provide a solution for the next release which will be probably this weekend. I will keep you up to date on that.

Regards
Johnny

Thank you @johnny looking forward to it.

Hello @Anwar ,

I am glad to inform you that latest version (3.1.15) now have the extra triggering for depended field. More specifically you can check the documentation here: JavaScript Events | Grocery CRUD - A PHP CRUD Generator Library

So for example in your case this will be something like this:

groceryCrudSetFieldValue('country_id', '181')
groceryCrudEmitReduxAction('depended-fields/update-dependency', {
  fieldName: 'country_id',
  fieldValue: '181'
});

Let me know if that is fixing your issue.

Regards
Johnny