Set Radio Button to value saved in database

robinPog 08 Jul, 2022
Hi
I have a radio button on my form with options Yes and No. Yes saves Y to the database and No saves N to the database. As this form is re-displayed to users to amend I need to set the radio button to the value saved in the data base but I cant find a way to do it. The value (Y or N) for the field shows correctly in the debug list.
For other fields to display the value from the database you need to include the Value & Placeholder option under Advanced Settings but that is not available for a Radio Button.
Please can you tell me how to set the button value
Thanks
Robin
Colnem 09 Jul, 2022
Hi

First, you read your database table by Action/Database/Read database
Yo set a name and a model name of your action: for exemple (bu default), name=read_data_n, model= model_n. You choose First Record.

Then you create a View Element Radio and set radio button value= {var:read_data_n.model_n.field_name_Y_or_N}
robinPog 11 Jul, 2022
Answer
1 Likes
To make this work I needed to do the following
1: Create a new Page Group which I called FormElements
2: Add a Radios option from the Fields drop down to this page
3: Define the Radio Buttons as follows:-
  1. Field Name: IncludeMast
  2. Add Option: Value: Y text Yes
  3. Add Option: Value: N text: No
  4. Under Advanced Settings add Dynamic Selections, then Add a Selection with a value of {var:Read_database.cfsd_Liftout.IncludeMast} (which is the field returned from the database
4: On the original Page where I want the Radio Buttons to show, instead of adding a Radios option from the Fields drop down add a View Reference from the Custom drop down and set the Referenced Unit to point to the Radio Buttons define on the FormElements page (as defined above)

Now my form shows correctly.
Unfortunately this is too complicated to explain to normal users who were able to do this easily using Chronoforms 4. It is a pity that the Value and Place Holder option is not available for Radio Buttons.

Thanks to Calnem for pointing me i the correct direction to unravel this convoluted method of setting radio buttons. I expect something similar applies to check boxes.
You need to login to be able to post a reply.