Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] Integer Type Field: Calculate Maximum Value Allowed Based on Calendar Year

9 years 4 months ago - 9 years 3 months ago #266870 by cbnewbie01
Dear support team,

I'd like to be able to set up a field for members to enter the year they enter the profession between 1945 and the current year. For administrative purposes, I would like to calculate the maximum value allowed based on the current calendar year so that I would not have to update the maximum value each year.

This would be similar to the Excel function of year(today()).

I have tried searching the forum and the web but couldn't find any relevant info. Your guidance would be greatly appreciated.

Best regards.
Last edit: 9 years 3 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 3 months ago #266909 by krileon
The validation parameters can't do any of that. They're just static checks. Best I can suggest for now is CB Query Field and its Query Validation then use a custom database query to validate its range. It's not ideal, but it should work. Once CB Code Field is developed you'd be able to have custom PHP validation, but that won't be for awhile.

The date fields have calculated range validation, but they'd be forced to supply a day and month as well, but you could hide those inputs using CSS as they'll auto-fill when selecting the year. So that could be a decent alternative.


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.

9 years 3 months ago #266955 by cbnewbie01

krileon wrote: The date fields have calculated range validation, but they'd be forced to supply a day and month as well, but you could hide those inputs using CSS as they'll auto-fill when selecting the year. So that could be a decent alternative.


Hi, Krileon,

Do you mean I may by-pass input of day and month using CSS? If so, how can I go about doing that?

In terms of auto-fill, will the system use current day and month or could we default that to a certain date (e.g. Jan 1)?

Thanks again!

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 3 months ago - 9 years 3 months ago #266986 by krileon

Do you mean I may by-pass input of day and month using CSS? If so, how can I go about doing that?

You can hide the month and day dropdowns with the below CSS.

Code:
#cbfr_FIELD_ID .combodate .month, #cbfr_FIELD_ID.combodate .day { display: none; }

The main issue is the dividers between the dropdowns will still show up. It maybe possible to hide those by changing the font color to same as background color. For example the following.

Code:
#cbfr_FIELD_ID .combodate *:not(.year) { display: none; color: white; }

Another option is to just move the year input after hiding the others.
Code:
#cbfr_FIELD_ID .combodate { position: relative; } #cbfr_FIELD_ID .combodate .month, #cbfr_FIELD_ID.combodate .day { display: none; } #cbfr_FIELD_ID.combodate .year { position: absolute; left: 0; }

In terms of auto-fill, will the system use current day and month or could we default that to a certain date (e.g. Jan 1)?

It'll always be January 1st for the month and day.


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.
Last edit: 9 years 3 months ago by krileon.

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

9 years 3 months ago #266991 by cbnewbie01
Perfect! I'll give that a try.

Many thanks!

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

9 years 3 months ago - 9 years 3 months ago #267037 by cbnewbie01
Hi, Kyle,

I just had to modify the codes a bit to make that work. Below, for your reference, are the final codes -

#cbfv_ID .combodate {
position: relative;
}
#cbfv_ID .combodate .month {
display: none;
}
#cbfv_ID .combodate .day {
display: none;
}
#cbfv_ID .combodate .year {
position: absolute;
min-width: 80px;
left: 0;
}
#cbfv_ID .fa-calendar {
position: absolute;
top: 50%;
left: 100px;
}
#cbfv_ID .fa-eye {
position: absolute;
top: 50%;
left: 120px;
}

For the digits for Year to show up on the Profile, I had to force a minimum width.

Since neither the icon for Calendar nor Eye (visibility) is aligned automatically relative to the drop-down box for Year, I also had to enforce absolute values for both their vertical and horizontal positions.

Hope this helps others who may be looking to make similar modifications.

Thanks!
Last edit: 9 years 3 months ago by cbnewbie01.
The following user(s) said Thank You: nant, krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum