image_select and required !=
Hey Guys,
I have a parent image select option along and a fields based on them. I am trying to use != in required argument and it seems to be not working. It seems to me like != operator is computed as ==
Could you post the 'fields' array you are using. It would help to try out it for myself. :)
Hey,
I did take a look at this particular problem and I found out that check_dependencies does compute correctly in the following code and variable "show" is actually true for "not equals to" required argument however that field or "show" variable is not being checked in $.redux.verify_fold.
Anyways, here is what I am using in the fields array:
array (
'id' => 'header_layout',
'type' => 'image_select',
'options' => array (
'v1' => 'http://localhost/wp-content/themes/A/images/patterns/header1.jpg',
'v2' => 'http://localhost/wp-content/themes/A/images/patterns/header2.jpg',
'v3' => 'http://localhost/wp-content/themes/A/images/patterns/header3.jpg',
'v4' => 'http://localhost/wp-content/themes/A/images/patterns/header4.jpg',
'v5' => 'http://localhost/wp-content/themes/A/images/patterns/header5.jpg',
),
'title' => 'Select a Header Layout',
'default' => 'v1',
),
array (
'desc' => 'Select which content displays in the top left area of the header.',
'id' => 'header_left_content',
'type' => 'select',
'options' => array (
'contactinfo' => 'Contact Info',
'socialinks' => 'Social Links',
'nav' => 'Navigation',
'empty' => 'Leave Empty',
),
'title' => 'Header Top Left Content',
'default' => 'Contact Info',
'required' => array('header_layout', '!=' , 'v1')
),
array (
'desc' => 'Select which content displays in the top right area of the header.',
'id' => 'header_right_content',
'type' => 'select',
'options' => array (
'contactinfo' => 'Contact Info',
'socialinks' => 'Social Links',
'nav' => 'Navigation',
'empty' => 'Leave Empty',
),
'title' => 'Header Top Right Content',
'default' => 'Navigation',
'required' => array('header_layout', '!=' , 'v1')
),
array (
'desc' => 'Select which content displays in the right area of Header 4.',
'id' => 'header_v4_content',
'type' => 'select',
'options' => array (
'tagline' => 'Tagline',
'search' => 'Search',
'taglinesearch' => 'Tagline + Search',
'banner' => 'Banner',
),
'title' => 'Header Content Area For Header #4',
'default' => 'Tagline + Search',
'required' => array('header_layout', '==' , 'v4')
),
array (
'desc' => 'Add HTML banner code for Header #4. The banner or image will display in Header 4 as long as you have Banner selected for the Header Content Area For Header #4 option above.',
'id' => 'header_banner_code',
'type' => 'ace_editor',
'mode' => 'html',
'title' => 'Banner Code For Header #4',
'required' => array('header_layout', '==' , 'v4')
),
array (
'desc' => 'Phone number will display in the Contact Info section of your top header.',
'id' => 'header_number',
'type' => 'text',
'title' => 'Header Phone Number',
'default' => 'Call Us Today! 1.555.555.555',
'required' => array('header_layout', '!=' , 'v1')
),
array (
'desc' => 'Email address will display in the Contact Info section of your top header.',
'id' => 'header_email',
'type' => 'text',
'title' => 'Header Email Address',
'default' => '[email protected]',
'required' => array('header_layout', '!=' , 'v1')
),
array (
'desc' => 'Tagline will display in the Contact Info section of your top header.',
'id' => 'header_tagline',
'type' => 'text',
'title' => 'Header Tagline',
'default' => 'Insert Any Headline Or Link You Want Here',
'required' => array('header_layout', '==' , 'v4')
),
I tracked some of the problem back to admin.min.js and solved the problem of kid panels not showing when clicking when set to !=, (line 177 was missing toString() but it's still not recognizing the difference between == and !=. I can't read that particular file easily as variable names are just letters. jQuery is not my strong suit. I'll have to kick this over to @Dovy.
@mharis - It looks like the original dev didn't finish hiw work. I am taking a crash course on jQuery as we speak, plus Dovy will get to it when he's done his latest project. If you see how to fix the problem, I'd be happy to work with you on it.
Yeah, there is no code at all which passes the following depedency code in JS to the verify fold function. I will take a look at it again to see if I can come up with a fix for all "required" argument conditions.
case '!=':
case 'not':
//if value was array
if (value2.indexOf('|') !== -1){
var value2_array = value2.split('|');
if($.inArray( value1, value2_array ) == -1){
show = true;
}
}else{
if(value1 != value2)
show = true;
}
break;
I think that was deliberate, since != and not are the same thing. If you try the not action, the same failure should still occur.
For this issue, so far I have the following patch available.
Still need to fix the issue where the fields array here https://github.com/ReduxFramework/ReduxFramework/issues/306#issuecomment-29147278 doesn't follow the required argument properly on page load.
Patch: https://www.dropbox.com/s/562wwi9xxzxzv9m/patch_commit_da388ce9634f.patch
@mharis - I'll take a look at this and give it some testing. The page load rendering code is in framework.php, which I will also be tinkering with.
I tried your patch. The options page itself wouldn't load. The problem seems to revolve around this:
redux_opts.folds[id].children[check_data.checkValue][check_data.checkId] = { 'show': show, 'hidden': false }
What does the error say in web dev console?
I forgot the page load code is in framework.php and messed around with making the page load options work with javascript too much.
TypeError: redux_opts.folds[id].children[check_data.checkValue] is undefined
Ah, this works for me locally.
I wonder what's different. I'll try again on a fresh Redux installation later today.
Duplicate and merged with another issue.
See: http://docs.reduxframework.com/redux-framework/arguments/using-the-required-argument/
Required now supports multiple parents, full nested, and limiting of CSS output if the field or parent is hidden.