Forums

A few V4 vs V5 How to questions

sactobob 08 Feb, 2016
Hey Bob,

A while back you gave some code for v4 to highlight request field titles in red and also put a red line in the field's input. This is the code that was used, is there similar method in V5? I assume there is, but field names have changed?

JavaScript:
[code]window.addEvent('domready', function() {
var required, cl, inputs, input, label, type, name, skip, marker;
marker = new Element('span', {
html: '',
styles: {
color: 'red',
fontWeight: 'bold'
}
});
inputs = $$('div input, div select, div textarea');
required = [];
inputs.each(function(el) {
cl = el.getProperty('class');
if(cl !== null && (cl.contains("validate['required'") || cl.contains("validate['group["))) {
required.push(el);
}
});
required.each(function(el) {
el.addClass('cf_required');
skip = false;
type = el.getProperty('type');
if(type == 'radio' || type == 'checkbox') {
if(name != el.getProperty('name')) {
label = el.getParent().getParent().getFirst('label');
name = el.getProperty('name');
} else {
skip = true;
}
} else {
label = el.getParent().getFirst('label');
}
if(label && !skip) {
label.grab(marker.clone(), 'bottom');
label.addClass('cf_required');
}
});
});[/code]

CSS:
label.cf_required {
  color: red;
}
input.cf_required, select.cf_required, textarea.cf_required {
  border-left: 6px solid red;
}


IE, see this website that I've used this on: http://jwjeep.com/parts-finder

2nd questions. In v4, after a submit in the "others" field there was a redirect option that can send the user to a Joomla article. I can't seem to find the corresponding method in V5. Edit: Nevermind, I see I had to go into Advanced mode and there's a Redirect option under Utilities to drag in the events options.๐Ÿ™‚

And finally.. I'm redoing this website's form from scratch on V5 (V4 import did not work,oh well), but also moving it to my cpanel platform. When the captcha field is displayed all it shows is a broken image. I'm suspecting I need to rebuild cpanel's webserver with a php extension/add-on, what lib is required for the captcha or is there a plugin I'm missing?
sactobob 08 Feb, 2016
Answer
I found the issue with the captcha...

[08-Feb-2016 08:41:57 UTC] PHP Fatal error: Call to undefined function GCore\Helpers\Captcha\imagettfbbox()

My Cpanel has GD lib installed, but that function also needs FreeType (TTF (FreeType) in cpanel)...
sactobob 08 Feb, 2016
That fixed captcha... So Q1 one is the last thing on the list.
GreyHead 10 Feb, 2016
Hi euoceo,

The labels are easier than with CFv4 as they have a class assigned. This CSS will change the text color to red:
label.required_label {
  color: red;
}

For the inputs there are two choices - the basic one is to add a Class e.g. cf_required to each required input - just add it to the Class box. Then this CSS will add the border:
.cf_required {
  border-left: 6px solid red !important;
}

If the form is too long to make this easy then you can add the classes with JavaScript like this.
jQuery(document).ready(function(jQ) {
  jQ(':input').each( function() {
    var el, className;
    el = jQ(this);
    className = el.prop('className');
    if ( /'required'/.test(className) ) {
      el.addClass('cf_required');
    }
  });
});

Bob
This topic is locked and no more replies can be posted.