[SOLVED] Code field validation

3 years 6 months ago #320702 by krileon
Replied by krileon on topic Code field validation

The error message should be language sensitive. But with a language string there is no translation.

How can I get the error message in the appripriate language?

Add a language override for the validation message to translate it into other languages. See the below on how to do this.

www.joomlapolis.com/blog/kyle/18701-language-overrides-have-arrived

So is it be possible to blcok the save button until date2 has noc validation error anymore and is set right?

No, since it's an ajax validation rule it won't block the button since the ajax could fail or take too long and cause the form to no longer work. Only validation rules that can be completely done in the browser can block the button. Will see if this can be improved so that ajax validation rules that were already successful can allow button blocking.

forge.joomlapolis.com/issues/8177


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 to join the conversation.

3 years 5 months ago #320752 by ericmuc
Replied by ericmuc on topic Code field validation
Hi,
Thanks for the answers!

Can you please give me also a hint hereto?

"I realised that the date2 also may not be greater than today.

How can I add this second validation in code field validation? Can you give me a hint how to use this here?"

Thanks, best regards
Eric

Please Log in to join the conversation.

3 years 5 months ago #320764 by krileon
Replied by krileon on topic Code field validation
Since it's just PHP you can add as many validations as you like using PHP. The below for example conditions a date to ensure it's not greater than today.

return strtotime( '[DATE_FIELD_2]' ) <= strtotime( 'now' );

If the input is valid return true if the input isn't valid return false. You can have multiple IF statements to handle the various validations. Example as follows.

if ( strtotime( '[DATE_FIELD_2]' ) > strtotime( 'now' ) ) {
	return false;
}

return return strtotime( '[DATE_FIELD_2]' ) >= strtotime( '[DATE_FIELD_1]' );


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.
The following user(s) said Thank You: ericmuc

Please Log in to join the conversation.

3 years 5 months ago #320776 by ericmuc
Replied by ericmuc on topic Code field validation
Hi,
Thanks,
if ( strtotime( '[DATE_FIELD_2]' ) > strtotime( 'now' ) ) {
	return false;
}

return strtotime( '[DATE_FIELD_2]' ) >= strtotime( '[DATE_FIELD_1]' );
is working for me now. Thanks again!
Eric

Please Log in to join the conversation.

3 years 5 months ago #320777 by ericmuc
Replied by ericmuc on topic Code field validation
Hi,

The error message should be language sensitive. But with a language string there is no translation.

How can I get the error message in the appripriate language?

Add a language override for the validation message to translate it into other languages. See the below on how to do this.

www.joomlapolis.com/blog/kyle/18701-language-overrides-have-arrived


I have added a language translation string but it doesn't work.

Please see the enclosed images.

Thanks, best regards
Eric
Attachments:

Please Log in to join the conversation.

3 years 5 months ago #320786 by krileon
Replied by krileon on topic Code field validation
Ok, I see an issue with how it's passing through language strings. You'd need to use the below language keys.

CODE_VALIDATION_SUCCESS
CODE_VALIDATION_ERROR

This will be fixed in a later release as I'm already mid-work on preparing a new stable release of CB Code Field.


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.237 seconds

Facebook Twitter LinkedIn