Problem with "Custom fields"

7 years 4 months ago #2918 by ajeje
Hi Staff,
I have a problem to add a custom field. I add a new field and I set "Check box" in "Field type", but when I go in section "Vehicles", the new field is always checked and I can't remove the check.

Best regards
7 years 3 months ago #2923 by Shoaib Rehmat
Hi brazorf,
The solution of your problem is you need to goto the directory path
components/com_jsautoz/views/seller/tmpl/formvehicle.php
in this file search for the code
	case 'checkbox':
		echo '<input type="checkbox" name="userfields_'.$k.'" id="userfields_'.$k.'_field" value="1" '.  'checked="checked"' .'/>';
		break;

and replace the above code with the following once
	case 'checkbox':
		$check = ($fvalue == 1) ? 'checked="checked"': '';
		echo '<input type="checkbox" name="userfields_'.$k.'" id="userfields_'.$k.'_field" value="1" '.$check.'/>';
		break;
7 years 3 months ago #2926 by ajeje
Replied by ajeje on topic Problem with "Custom fields"
Thank you for your reply. I have replaced your code but the problem remain. The problem is in backend not in frontend.
After I have added a new "Custom Field" I go in section "Vehicle", but the new field is always checked and I can not remove the check.
7 years 3 months ago #2928 by Shoaib Rehmat
Hi brazorf,
The solution of your problem is you need to goto the directory path
administrator/components/com_jsautoz/views/vehicle/tmpl/formvehicle.php

search for the code
case 'checkbox':
echo '<input type="checkbox" name="userfields_'.$userfield_count.'" id="userfields_'.$userfield_count.'_field" value="1" '.  'checked="checked"' .'/>';
break;

and replace the above code with the following once
case 'checkbox':
$check = ($fvalue == 1) ? 'checked="checked"':'';
echo '<input type="checkbox" name="userfields_'.$userfield_count.'" id="userfields_'.$userfield_count.'_field" value="1" '.  $check .'/>';
break;
7 years 3 months ago #2932 by ajeje
Replied by ajeje on topic Problem with "Custom fields"
The custom fields have too many problems.
With your solution, when I go in section vehicle the new field is not checked but in frontend appear with the writing "false".
If I check the new field in frontend appear with the writing "true", and if I try to remove the check, I can not do it.
7 years 3 months ago #2933 by Shoaib Rehmat
Check box related problem is solved by given solutions replace both the front end and back end code as a mention then the check box will work properly in both the end.
Time to create page: 0.120 seconds

Please publish modules in offcanvas position.