Forums

Direct row editing using Radio Buttons

MainsailSoftware 09 Jul, 2015
I have been using Direct Row Editing successfully with a two item radio button. Selecting the appropriate button correctly updates the underlying database value as expected.

The only problem I am having is how to get the correct radio buttons to be initialized to the existing data value.

Is there an example that shows how I can do this? I am not able to find anything in the forums.

Here is the Field code I am using:
entrant.boat_type:<input type="radio" name="entrant[{entrant.id}][boat_type]" id="boat_typeP" value="P">Power</input><br/><input type="radio" name="entrant[{entrant.id}][boat_type]" id="boat_typeS" value="S">Sail</input>


I have tried adding PHP code to set "checked", but that does not seem to work and is not being interpreted with in the Field entry.

How can I get the radio buttons to be initialized to the underlying data value?
MainsailSoftware 09 Jul, 2015
Answer
I figured this one out, or at least have it working properly.

I removed the above line from the Field box and put the following in the PHP Functions box:

entrant.boat_type:return '<input type="radio" name="entrant['.$row["entrant"]["id"].'][boat_type]" id="boat_typeP" value="P"'.($cell=="P"?"checked":"").'>Power</input>'.'<br/><input type="radio" name="entrant['.$row["entrant"]["id"].'][boat_type]" id="boat_typeS" value="S"'.($cell=="S"?"checked": "").'>Sail</input>';


I was surprised that this worked as I figured that to successfully have the _SELECTOR_ work and correctly update the proper fields, the code for each field had to be in the Field box. Evidently, if the _SELECTOR_ is used, the PHP Functions box works just as well and allows PHP code to be utilized.
This topic is locked and no more replies can be posted.