Database driven radio buttons

1. Download and install the new rodakino version

You find the new version here: rodakino_0_2_3.tgz

Also look here for  rodakino RAD download and installation . Be sure to install rodakino_0_2_3.tgz, not an older one !!!



As with the checkbox, the radio buttons should automatically be synchronized with the corresponding database field.

Problems: We have always more than one radio button, because for each distinct value of our database field we need an extra radio, i.e. an extra INPUT field of type "radio".

Radio button groups are identified by their name, which is the next problem: We define the radio buttons in the row_template, and if we retrieve more than one database row, all the radio buttons of all the rows are put into the same group, which is NOT, what we want.


        <div class="roda_field" name="TEST_RADIO">
          <input type="radio" id="TEST_RADIO_A" name="TEST_RADIO" value="A" checked>
            <label for="TEST_RADIO_A">A</label>
          <input type="radio" id="TEST_RADIO_B" name="TEST_RADIO" value="B">
            <label for="TEST_RADIO_B">B</label>
          <input type="radio" id="TEST_RADIO_C" name="TEST_RADIO" value="C">
            <label for="TEST_RADIO_C">C</label>

First, as you can see in our example, rdbw_input_tests, we define a <div> around the radio's and tag it as one roda_field.

Second, the rodakino framework adds the rownum to each name of a radio of thesame row (from TEST_RADIO it generates TEST_RADIO___1 for the radio button group and so on ...).

Furthermore, rodakino does all the necessary logic behind the curtain.


2. We expand our test database table

$> psql -U node node

alter table INPUT_TESTS add TEST_RADIO char(1); -- A...1st level, B...2nd level, C...3rd level


3. We reuse the rodakino window rw_input_tests.hbs

and rdbw_input_tests of course.

Everything is already done in version 0_2_3 ! Have a look in .../rodakino/app/roda_windows and in .../rodakino/app/roda_dbwindows


rw input tests radio