DMXzone Database Updater PHP Support Product Page

Answered

Prepopulating Checkbox, Radio & Select fields with existing data

Asked 29 Jan 2016 08:09:42
1
has this question
29 Jan 2016 08:09:42 David Woolley posted:
I'm preparing an update form to be used with DB Updater, but having trouble populating the checkbox, radio & select fields from the data bindings.

No problem with prepopulating text input fields - just bind the relevant input.value

Do you have a guide/tutorial/video explaining how to bind the values to checkbox, radio & select fields?

I've tried a few combinations but always get the checkbox to be unchecked when it should be checked, and the Select menu always showing the first item in the list.

Cheers
Dave

Replies

Replied 29 Jan 2016 11:54:08
29 Jan 2016 11:54:08 Teodor Kuduschiev replied:
Replied 29 Jan 2016 13:23:17
29 Jan 2016 13:23:17 David Woolley replied:
Thanks Teodor
I realize now that the key to prepopulating a checkbox field for the update record form is to use BOTH these data binding values below:

<input name="fieldname" type="checkbox" id="fieldname" value="{{fieldname}}" data-binding-checked="{{(fieldname ==1)}}">

fieldname uses tinyint 0 & 1

Quite a bit of testing to reach this outcome ...

Dave
Replied 29 Jan 2016 14:47:37
29 Jan 2016 14:47:37 David Woolley replied:
Now for prepopulating the select field in my update record form.

The select items are from a child table - no problem creating this dynamic list by using a data source for the list items. then creating a repeat region for the field. I've done this for the Insert Record form.

But how to ensure that the relevant select item is listed for the existing record in the Update Record form?

Cheers
Dave

Replied 29 Jan 2016 15:03:49
29 Jan 2016 15:03:49 Teodor Kuduschiev replied:
I am not sure what exactly do you need to achieve?
All you need to do is to just filter the data source for the dropdown list.
Replied 01 Feb 2016 13:26:02
01 Feb 2016 13:26:02 David Woolley replied:
When a record is edited, the entire menu/list should be displayed with the appropriate item highlighted, but this menu item can be changed of course when updating. I tried filtering the child ID on the parent ID in the data source but of course this only shows one item in the list.

The Dreamweaver Dynamic list/Menu server behavior allows you to 'Select value equal to'
where you choose the appropriate child ID from the parent table recordset.

For example:

Products is parent table with primary key ProductID & foreign key CategoryID

Categories is child table with values for menu select options with fields: CategoryID & category

Select value equal to: <?php echo $row_rsProducts['CategoryID'] ?>

where rsProducts is the recordset for the Products table.


I would illustrate this with a few screenshots but can't seem to add an image here.

I just need to know how to do the same thing for HTML5 Data Bindings, Database Connector & Updater.
This is definitely not obvious.

Dave










Replied 01 Feb 2016 13:38:47
01 Feb 2016 13:38:47 Teodor Kuduschiev replied:
Please check the following tutorial: www.dmxzone.com/go/22724/master-detail-relationship-with-dmxzone-database-connector
As i already explained - all you need to do is to filter one repeat region with the value from another.
Replied 03 Feb 2016 14:43:56
03 Feb 2016 14:43:56 David Woolley replied:
I managed to sort this out by using URL parameters, as I have a master page with a list of records in a table, linked to a detail page for the update form.

I added an extra parameter to the URL for the select element origin_id like so:

<a href="edit_case_detail.php?case_id={{case_id}}&origin_id={{origin_id}}" class="btn btn-xs btn-primary" type="button">EDIT</a>

Then bound select.data.value with the URL parameter for the origin_id to the select element in the detail page to be updated.

Now that I've managed to figure out how to preselect list/menu items, I have another question:

I'm using Advanced HTML Editor for textarea fields to be edited for updating the record, but can't work out how to show the existing contents of the field in the AHE box. I tried binding textarea.data.value to the field, but no content shows.

Any ideas?

Slowly getting there by trial and error!

Cheers
Dave

Reply to this topic