Keyword

Validation alerts are blank in front-end editor

  • Robert Peterson
  • Robert Peterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 9 months ago #122002 by Robert Peterson
Validation alerts are blank in front-end editor was created by Robert Peterson
Hello, all!

I seem to have a weird bug in my version of K2. On the front-end editor, the validation alert is blank:

Attachment not found



I checked the source code, and the div itself is empty.

This alert is working fine on the back-end.

Any idea where this text is generated, so I can repair it? I need my users on the front end to know what to do.

Thanks!!!

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

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 9 months ago #122003 by Yiota
Do you have any required extra fields? Usually this alert comes from them.

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

  • Robert Peterson
  • Robert Peterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 9 months ago #122004 by Robert Peterson
Replied by Robert Peterson on topic Re: Validation alerts are blank in front-end editor
Yiota: Yes, I have required extra fields.

On the back-end, the alert displays just fine:

Attachment not found



See what I mean? On the front-end, the text is missing entirely. Only the blue box appears. That's a problem for me, because I don't want my users to get confused.

Any ideas? Thanks!!!

b
Attachments:

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

  • Robert Peterson
  • Robert Peterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 9 months ago #122005 by Robert Peterson
Replied by Robert Peterson on topic Re: Validation alerts are blank in front-end editor
Just to confirm, here's a look at the code for those alerts on the front end:

Attachment not found



See? It's just an empty UL.

Anyway, I'm trying to scavenge some code from the back-end editor. Any guidance would be appreciated!!!

Thanks!

b
Attachments:

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

  • Robert Peterson
  • Robert Peterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 9 months ago #122006 by Robert Peterson
Replied by Robert Peterson on topic Re: Validation alerts are blank in front-end editor
OK, the validation alerts are generated in the K2.js file in this code:
// Extra fields validation
function validateExtraFields() {
	$K2('.k2Required').removeClass('k2Invalid');
	$K2('#tabExtraFields a').removeClass('k2Invalid');
	var response = new Object();
	var efResults = [];
	response.isValid = true;
	response.errorFields = new Array();
	$K2('.k2Required').each(function() {
		var id = $K2(this).attr('id');
		var value;
		if ($K2(this).hasClass('k2ExtraFieldEditor')) {
			if ( typeof tinymce != 'undefined') {
				var value = tinyMCE.get(id).getContent()
			}
		} else {
			var value = $K2(this).val();
		}
		if (($K2.trim(value) === '') || ($K2(this).hasClass('k2ExtraFieldEditor') && $K2.trim(value) === '<p></p>')) {
			$K2(this).addClass('k2Invalid');
			response.isValid = false;
			var label = $K2('label[for="' + id + '"]').text();
			response.errorFields.push(label);
		}
	});
	$K2.each(response.errorFields, function(key, value) {
		efResults.push('<li>' + value + '</li>');
	});
	if(response.isValid === false) {
		$K2('#k2ExtraFieldsMissing').html(efResults);
		$K2('#k2ExtraFieldsValidationResults').css('display','block');
		$K2('#tabExtraFields a').addClass('k2Invalid');
	}
	return response.isValid;
}

But for some reason, it's not getting invoked on the front end. Weird!

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

  • Robert Peterson
  • Robert Peterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 9 months ago #122007 by Robert Peterson
Replied by Robert Peterson on topic Re: Validation alerts are blank in front-end editor
Here's a working solution. In a template override, replace this code:
<ul id="k2ExtraFieldsValidationResults"></ul>

... with this:
<div id="k2ExtraFieldsValidationResults">
								<h3><?php echo JText::_('K2_THE_FOLLOWING_FIELDS_ARE_REQUIRED'); ?></h3>
								<ul id="k2ExtraFieldsMissing">
									<li><?php echo JText::_('K2_LOADING'); ?></li>
								</ul>
							</div>

K2 team, I don't know if that's a workable solution for the core, but it's working for me. Thanks!

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

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 9 months ago #122008 by Yiota
The code above exists in the itemform.php file. Since you have used template overrides then you need to update this file as you correctly did.

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


Powered by Kunena Forum