I am currently working in a CRUD above (please refer to the image).
When I was using the old enterprise edition, I can actually use JQuery to hide fields or add text to specific input elements.
Now I am currently using Grocery CRUD Enterprise 3.0.4 and cannot execute the task using the same method. Are there any workarounds for this?
However, I got lost in how could actually get to control or code for the specific example.
I wanted to add default values to other fields based on the selection made on the School Origin field.
For example if I select Senior High School, the values for the related fields for College and Vocational School Level would be ān/aā.
I hope someone can give me insights on how to do this. Your help would be highly appreciated.
Thank you very much!
Unfortunately though visually the values are present, it was not saved to the database during saveā¦
I do hope this feature or action be integrated to the later release of GroceryCRUD Enterprise, this would be very useful and handyā¦
Hello @larasmith ,
After spending lot of time researching and asking ChatGPT, it seems actually impossible without a code change due to React architecture.
It seems that I will need to add extra code for that in order to achieve the value change. However this may need some time (probably for next week) and I canāt find another work-around for this for now, sorry. I had some proof of concepts of how to do it so I am not that far away from that.
As promised Iāve created a new JavaScript method that can set the value of a field. You will need to upgrade to version 3.0.7.
The new JavaScript function name is called groceryCrudSetFieldValue and it take two parameters like the example:
groceryCrudSetFieldValue(fieldName, fieldValue)
For example in your case you will do something like this:
Hello, I tried this groceryCrudSetFieldValue but donāt work. I have GC 3.0.11 updated today.
When I tried groceryCrudSetFieldValue(āfieldNameā, āvalueā) in the console of the browser, it returns undefined. Same problem into the view of the output of Grocery Crud.
What I have to do?
Thanks
Please make sure that you have āpublish_eventsā => true into the Grocery CRUD configuration file. Also make sure that you load groceryCrudSetFieldValue only after add or edit form is opened. For example with the event:
window.addEventListener('gcrud.form.edit-load', ({detail}) => {
// use groceryCrudSetFieldValue here
});