Check Box Updating

13 years 6 months ago #146212 by makitso
Check Box Updating was created by makitso
Site has a registration with two fields, a checkbox and a text field. After registration, the user can no longer update them when updating the profile.

In the profile, I would like both fields grayed out (set so the user can't update them).

When I use the code below, the fields are grayed out. However when the user updates other fields in the profile:

1. The membertext field is left unchanged in the database. Correct behavior.

2. The membercheck field is changed to unchecked (zero) database -- which is what is causing me the problem. I don't want this value to be updated.

I don't know if this is a bug or I am doing something wrong.

NOTE## I can't set the fields to read only for other reasons.


jQuery(document).ready(function(){

jQuery('#membercheck').attr("disabled", true);
jQuery('#membertext').attr("disabled", true);

Thanks

Post edited by: makitso, at: 2010/11/14 15:58

Please Log in to join the conversation.

13 years 5 months ago #146279 by krileon
Replied by krileon on topic Re:Check Box Updating

In the profile, I would like both fields grayed out (set so the user can't update them).

Edit the fields in Field Management and set them as Read Only. They'll then only be editable from Registration or from backend User Management.

NOTE## I can't set the fields to read only for other reasons.

Setting them to read only is best solution. What are your other reasons? If you need them editable by Moderators then you can use documentation subscriber CB Privacy plugin which will allow you to make the field only editable by moderators after registration.

Your jQuery is just setting the field as disabled for display purposes, but this does not set it disabled internally. By doing this you now have a security vulnerability. I can for example use Firebug and edit the DOM removing the disabled tag then edit the field and save, tada.. I've just bypassed your code.

Post edited by: krileon, at: 2010/11/15 19:15


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.

13 years 5 months ago #146341 by makitso
Replied by makitso on topic Re:Check Box Updating
Thanks for the reply.

Members and non-members can register.

When a new user registers they can check if there a member (checkbox) and provide their memberid (text field) or if they can not provide these two fields,e.g. not a member.

THEN at a later time, they should be able, in their profile, update these two fields. Once these have been validated the fields are grayed out and not modifiable in the future. Setting the checkbox field to read only prevents a registered user from updating these two fields during in their profile.

The problem is that CB handles the checkbox and text field differently during the update. If I knew where the update code was I would hack it but -- its quite complicated i.e. not sure if its javascript, ajax or the like.

ROb

Please Log in to join the conversation.

13 years 5 months ago #146363 by krileon
Replied by krileon on topic Re:Check Box Updating
Best approach would be to develop a new integration that allows creation of a new fieldtype for your exact purpose. Examples of fieldtype plugins are documentation subscriber ajax text and file fieldtypes. As your jquery usage is a vulnerability as again I could just edit the dom and bypass your jquery disabled usage.


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.

13 years 5 months ago #146368 by makitso
Replied by makitso on topic Re:Check Box Updating

Your jQuery is just setting the field as disabled for display purposes, but this does not set it disabled internally.


the db has membercheck = 1 and membertext = 1234.

The display in the profile is grayed out with:

jQuery('#membercheck').attr("disabled", true);
jQuery('#membertext').attr("disabled", true);

After the page is updated:

the db has membercheck = 0 and membertext = 1234.

The problem is that an update will not change the membertext field in the database. However, the checkbox [membercheck] is changed from 1 to 0 in the database. My point is that the two fields are handled differently.


jQuery('#membercheck').attr("disabled", true);
jQuery('#membertext').attr("disabled", true);

Please Log in to join the conversation.

13 years 5 months ago #146384 by krileon
Replied by krileon on topic Re:Check Box Updating
This is because internally CB does not know to not update that field. When the field is disabled it'll pass a blank value in a checkbox case it will pass 0. CB has internal code to prevent read only fields from updating. By not using read only it's acting like a normal field.

Also, again, your jquery is a complete vulnerability as I can and many others very easily edit the dom with Firefox and bypass the jquery disable. The absolute best approach is to create a new fieldtype plugin that provides a field which means your absolute needs. Your needs are too customized and specific for CB to do out of the box.


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.207 seconds

Facebook Twitter LinkedIn