I am using webmaker 5.
I added an editable row control form the rich composite controls on the palette. I set the repeating contact page display binding to point to the record set that will be used to show multiple subrecords for customer contact information (xpath: /mvc:eForm/mvc :D ata/Customer_Contact/record). In this data set I have 3 values for each row, the contact_value, contact_type_id, and customer_id. The contact_type_id value is to be chosen using a dropdown select box. I have the list of possible contact types pulled from the database in another section of the virutal xml document input to the page. So, the data binding for the select box is set up such that the page display binding is a relative reference to the contact_type_id value from the /mvc:eForm/mvc :D ata/Customer_Contact/record spot in the XML document, but the dynamic dropdown has value entity set to contact_type_id and display value entity set to name from the /mvc:eForm/mvc :D ata/Contact_Type/record area of the input xml document.
Everything is working until we try to display an existing record. New rows can be added and deleted just fine and the changes reflect correct values in the database. The problem is when we load up an existing record that has contact information, all the contact type dropdowns on the editable row show the last option in the list, no matter what. When the record is saved again without modifying anything in the table, the contact type ID gets changed to the id for the last type value in the list of contact type options.
So it appears there is something wrong with the HTML webmaker is generating for a repeating editable table content that has a dynamic select box with values from a database. This is the HTML that gets generated for the select box when a dynamic select box is in the repeating row for the sub record display:
<select class="select" id="repeatingEditableTableContactInfo1contact_type_id" name="repeatingEditableTableContactInfo1contact_type_id">
<option value="">
</option>
<option selected="selected" value="1">Email</option>
<option selected="selected" value="2">Fax Number</option>
<option selected="selected" value="3">Commercial Phone Number</option>
<!-- ...snip... -->
</option>
</select>
...
As you can see, for some reason the webmaker engine is putting the selected attribute on each and every dropdown option, and then the javascript that makes the table dynamically editable I suppose doesn't know which option to really select for display on the record so it picks the last option from the html with the selected attribute set, and this is why the display is getting messed up and clobbering the values that were loaded from the database.
Now, what is VERY strange is when I set the dropdown to be a static select box and then hand jam all the contact type values from the database into the data constraints area of the properties of the select box, keeping the IDs the same as from the database, everything works as expected and when a record is loaded the correct dropdown options is selected by default and only one option has the selected attribute in the html.
What is going on here and how do I fix this so that I can have a select box have dynamically enumerated values from a database inside the repeating editable row control?
I added an editable row control form the rich composite controls on the palette. I set the repeating contact page display binding to point to the record set that will be used to show multiple subrecords for customer contact information (xpath: /mvc:eForm/mvc :D ata/Customer_Contact/record). In this data set I have 3 values for each row, the contact_value, contact_type_id, and customer_id. The contact_type_id value is to be chosen using a dropdown select box. I have the list of possible contact types pulled from the database in another section of the virutal xml document input to the page. So, the data binding for the select box is set up such that the page display binding is a relative reference to the contact_type_id value from the /mvc:eForm/mvc :D ata/Customer_Contact/record spot in the XML document, but the dynamic dropdown has value entity set to contact_type_id and display value entity set to name from the /mvc:eForm/mvc :D ata/Contact_Type/record area of the input xml document.
Everything is working until we try to display an existing record. New rows can be added and deleted just fine and the changes reflect correct values in the database. The problem is when we load up an existing record that has contact information, all the contact type dropdowns on the editable row show the last option in the list, no matter what. When the record is saved again without modifying anything in the table, the contact type ID gets changed to the id for the last type value in the list of contact type options.
So it appears there is something wrong with the HTML webmaker is generating for a repeating editable table content that has a dynamic select box with values from a database. This is the HTML that gets generated for the select box when a dynamic select box is in the repeating row for the sub record display:
<select class="select" id="repeatingEditableTableContactInfo1contact_type_id" name="repeatingEditableTableContactInfo1contact_type_id">
<option value="">
</option>
<option selected="selected" value="1">Email</option>
<option selected="selected" value="2">Fax Number</option>
<option selected="selected" value="3">Commercial Phone Number</option>
<!-- ...snip... -->
</option>
</select>
...
As you can see, for some reason the webmaker engine is putting the selected attribute on each and every dropdown option, and then the javascript that makes the table dynamically editable I suppose doesn't know which option to really select for display on the record so it picks the last option from the html with the selected attribute set, and this is why the display is getting messed up and clobbering the values that were loaded from the database.
Now, what is VERY strange is when I set the dropdown to be a static select box and then hand jam all the contact type values from the database into the data constraints area of the properties of the select box, keeping the IDs the same as from the database, everything works as expected and when a record is loaded the correct dropdown options is selected by default and only one option has the selected attribute in the html.
What is going on here and how do I fix this so that I can have a select box have dynamically enumerated values from a database inside the repeating editable row control?
RE: problem with editable row and database driven dropdown menu
If a select box field is contained within a Repeat (e.g. editable row), and a relative XPath is required (outside of repeat to another repeating list), the 'repeat variable' will need to be used for this XPath if this is a select box, radio button or multiple checkbox control with dynamic options.
The XPath Guidelines section will detail the repeat variables available. This is because the Options Location value used to find the set of options to display (drop-down list) will alter the current context point of where the XPath matching starts from.
For your field that has the issues, have a look at the bindings for the drop-down list.
See if there is some comments below the XPath Guidelines heading something like this:
This field is contained within one (or more) repeating groups.
Therefore you can use the following XSLT variable names in your XPaths to refer to the current entry in each node-set:
$<YOUR REPEAT>_repeatLoopEntry - Variable containing the current entry in the <YOUR REPEAT>_repeat group
The context for these XPaths is : /mvc:eForm/mvc :D ata/.... YOUR REPEAT XPATH
All XPaths are evaluated against the data going to the page.
So, you will need to use the variable name to prefix the selected field value.