Forums

DBRead - How does it work? (still no clue …)

burf 07 Dec, 2018
Hi,

though reading through the forum I still don't get it … How does the DBRead function work with my simple form?

What I plan: A simple form with 20 dates over the year where users can check a certain date in order to make an appointment with me.

What has been done:
  1. Designer: Form with two Checkboxes, Label "January 11" (field name "Datum1") and Label "January 12" (field name "Datum2"), with "options" "Yes" and "No", and a submit button to my table.
  2. Setup: On load (Load Java, Load CSS, DB Read, HTML Render), on submit (Handle Arrays, DB Save, Display Message)
  3. DB Read options are: active, Table name, multiple read YES, ModelL-ID active YES, ModelL-ID "Data"
When I test the form, I can check the boxes and the entries are saved in the table. However, when I open the form again, no box is selected, which means, that the "read" did not work.

What do I have to do? – Thanks for your help!
Carsten
healyhatman 07 Dec, 2018
If you're creating a brand new form, why wouldn't you make it in the newer and much easier CF6 ?
burf 10 Dec, 2018
Thanks for the hint. I installed v6, with no success in creating the new form.

The "debugger" action says that the form reads the data from the table correctly, but the respective check boxes are not checked/unchecked accordingly.

Attached are three images: the designer section and the setup-load and setup-submit section. What will I need to change in order to have the respective checkboxes checked or unchecked when the form is opened? (The checkbox shall be checked if it has been checked by any user.)

Any help? Thanks a lot.

Carsten


healyhatman 10 Dec, 2018
OK so first thing - you have your data read set to All Matching. Set it to First Matching.

Secondly, it hasn't checked the checkbox because you haven't told it to. Go to the Advanced tab of the checkbox. Under "Checked status provider" you'll need to put in
{var:read_data4.modelname.fieldname}
burf 10 Dec, 2018
1) Thanks. That was it! Would never have found this solution …

2) At the "Events" tab of the checkbox I can add "actions". I would like to add that the checkbox is "checked" & "disabled"=faded out, if the last matching record says "checked".

However, if I add "on check" a "disabled" action, it will not save the status "checked". And if I add "hide", it will immediately "hide" the checkbox, and don't show again.
healyhatman 10 Dec, 2018
An input that is disabled is not sent when the form is submitted - this is standard HTML behaviour.
burf 10 Dec, 2018
so there is no (easy) way to have an already checked checkbox read and show, but faded out like in this image?

GreyHead 11 Dec, 2018
Hi burf,

Have you tried setting the checkbox to readonly instead of disabled? You may need to use Custom CSS to do that.

Bob
burf 11 Dec, 2018
Hi Bob,

since I am not at all an expert in Custom CSS, I'll probably have to find another way … CF6 is nice and big tool, but some things are getting too complicated for amateurs like me. (The rule for the checkbox would be "set checkbox to readonly if any record says "checked"".)

Thanks, Carsten
healyhatman 11 Dec, 2018
Why did it need to be sent in the form data anyway? What's wrong with just disabling it?
burf 11 Dec, 2018
Thanks for your reply.

I have a list of lets say ten dates, reserved for consulting employees of a certain company. They now have to book a certain date, and only one person shall be able to book one certain date. When it is booked, nobody else should be able to book that same date.

If I "disable" the item, no one will be able to book that certain date, not even the first to come, since it will just do nothing.

If I "hide" the item, it will immediately disappear, and cannot be undone by the person who might only accidentally checked it.

Any unchecked item should be able to be checked once, and only once, and afterwards it should be faded out or at least completely hidden.

Carsten
GreyHead 11 Dec, 2018
Hi Carsten,

Only one person will be submitting the form form themselves if I understand correctly. If they are only allowed to select one date then use radio buttons instead of checkboxes. Once they submit the form you can mark that data as 'taken' and remove it or disable it from the radio button set for later users.

Technically it is possible that a second form gets submitted for the same data before the first user has completed and submitted their form - if you think that this is possible then you should add a server-side check to confirm that the selected date is still available,

Bob
burf 11 Dec, 2018
Hi Bob,
thanks. It really seems to me, that all of this would be possible – but that for me it is to complicated. Never mind, I will still use CF for other questionnaires.

Testing with radio buttons I now again have the same DBRead problem as above, that the information is not read when opening the form again (the "Checked status provider"-field is missing). – Not mentioning, that I would need to add a server-side check as written above …

And finally it also depends on my question #382145 from earlier today. If it is getting more difficult I might stay with CF5.

Thank you very much.
Carsten
This topic is locked and no more replies can be posted.