Skip to Content Skip to Menu

Field group issue

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
2 years 10 months ago - 2 years 10 months ago #327245 by galanopd
Field group issue was created by galanopd
Based on field groups education and work, I have created a new one called "driving licences". This way various types of driving licences the user possesses may be added. It kind of works but I am facing 2 issues.

1. When I set a new driving licence by setting cb_driving_licence_cat (category, select field), cb_driving_licence_issued (date field) and cb_driving_licence_expire (date field), only the cb_driving_licence_cat is saved. Then I have to edit and set again the 2 date fields and save again and then it works. Exactly the same happens with work field group and education (only year there) from CB->Quickstart. Checked on CB demo website and there they seem to be working ok.

2. The <script> shows the error message only for the first record although according to the dates I have set it should appear to the others too. Please check the image.
Code:
[cb:if cb_driving_licence_cat!=""] <div class="row no-gutters"> <div class="col-3 text-center; left !important";> <span class="far fa-address-card fa-4x"></span> <strong><span style="font-size: 250%;">[cb:userfield field="cb_driving_licence_cat" /]</span></strong> </div> <div class="col-3 pl-1"> <div> <span style="font-size: 110%;">Κατηγορία διπλώματος: <strong>[cb:userfield field="cb_driving_licence_cat" /]</strong></span> </div> [cb:if cb_driving_licence_issued!="" and cb_driving_licence_issued!="0000-00-00" or cb_driving_licence_expire!="" and cb_driving_licence_expire!="0000-00-00"] <span style="font-size: 110%;">[cb:userfield field="cb_driving_licence_issued" /]</span> [cb:if cb_driving_licence_issued!="" and cb_driving_licence_issued!="0000-00-00" and cb_driving_licence_expire!="" and cb_driving_licence_expire!="0000-00-00"] - [/cb:if] [cb:if cb_driving_licence_expire="" or cb_driving_licence_expire="0000-00-00"] - <span style="font-size: 110%;">Σήμερα</span> [/cb:if] <span style="font-size: 110%;">[cb:userfield field="cb_driving_licence_expire" /]</span> [/cb:if] </div> <div id="output"; class="col-3 pl-1"> <script> var today = new Date(); var expDate = "[cb:userfield field="cb_driving_licence_expire" /]"; var tmp = expDate.split("/"); var date2 = new Date(tmp[2],tmp[1]-1,tmp[0]); var pattern = /[0-3][0-9]\/(0|1)[0-9]\/(19|20)[0-9]{2}/; //Regex to validate date format (dd/mm/yyyy); if (pattern.test(expDate)) { var y1 = today.getYear(); var y2 = date2.getYear(); } if (y2>=y1 && y2<=y1+1) { var html = "Your licence will expire soon"; document.getElementById('output').innerHTML = html; } else if (y2<y1) { var html = "Your licence has expired"; document.getElementById('output').innerHTML = html; } else if (y2>y1+1) { var html = "Your licence is valid"; document.getElementById('output').innerHTML = html; } </script> </div> </div> [/cb:if]

Last edit: 2 years 10 months ago by galanopd.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48424
  • Thanks: 8274
  • Karma: 1443
2 years 10 months ago #327254 by krileon
Replied by krileon on topic Field group issue

1. When I set a new driving licence by setting cb_driving_licence_cat (category, select field), cb_driving_licence_issued (date field) and cb_driving_licence_expire (date field), only the cb_driving_licence_cat is saved. Then I have to edit and set again the 2 date fields and save again and then it works. Exactly the same happens with work field group and education (only year there) from CB->Quickstart. Checked on CB demo website and there they seem to be working ok.

Sounds like there might be a problem with date fields in CB Field Group when a new row is inserted. Was pretty sure I fixed that already. Is CB and all your installed CB plugins completely up to date?

2. The <script> shows the error message only for the first record although according to the dates I have set it should appear to the others too. Please check the image.

Your JS is just updating the same element over and over. Specifically the element with an id of output. Use a CSS class and just loop through the elements to avoid this issue.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
2 years 10 months ago - 2 years 10 months ago #327272 by galanopd
Replied by galanopd on topic Field group issue

Sounds like there might be a problem with date fields in CB Field Group when a new row is inserted. Was pretty sure I fixed that already. Is CB and all your installed CB plugins completely up to date?


Yes, all up to date. The issue doesn't appear in the first record but to all the rest

Your JS is just updating the same element over and over. Specifically the element with an id of output. Use a CSS class and just loop through the elements to avoid this issue.


Thanks, I will check it
Last edit: 2 years 10 months ago by galanopd.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48424
  • Thanks: 8274
  • Karma: 1443
2 years 10 months ago #327280 by krileon
Replied by krileon on topic Field group issue

Yes, all up to date. The issue doesn't appear in the first record but to all the rest

I'm not having any such issues in my tests. Please PM backend super user login credentials and will take a look.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum