I am using webmaker 5.
I have a database schema like so: I have a request record which is linked to a customer record, and each customer record can have multiple phone numbers and each phone number can have a different type, so there is a records table, a customers table, a contacts table, and a contact_type table.
The question is how do I make it so webmaker can first show one empty repeat row for the phone number of a customer, then have a button to dynamically add a new phone number row with it's own phone number box and type dropdown such that a user can have any number of phone numbers. This needs to be done without putting any intermediate results into the database so that records only get created when the user fills the entire form out so then if the user starts filling out the form then stops there are no orphaned records in the DB.
I need to know how to do this in the form designer, and then what I would need to do in the controller backend.
The only method I've found to do this is to basically have hard coded into the form a set number of record sets and just hide the ones I am not using and when the user clicks the button to add a new row I would then toggle visibility of one of the hidden record sets. This is a sloppy solution and I dont like it. Is there any other method of doing what I am trying to do?
I have a database schema like so: I have a request record which is linked to a customer record, and each customer record can have multiple phone numbers and each phone number can have a different type, so there is a records table, a customers table, a contacts table, and a contact_type table.
The question is how do I make it so webmaker can first show one empty repeat row for the phone number of a customer, then have a button to dynamically add a new phone number row with it's own phone number box and type dropdown such that a user can have any number of phone numbers. This needs to be done without putting any intermediate results into the database so that records only get created when the user fills the entire form out so then if the user starts filling out the form then stops there are no orphaned records in the DB.
I need to know how to do this in the form designer, and then what I would need to do in the controller backend.
The only method I've found to do this is to basically have hard coded into the form a set number of record sets and just hide the ones I am not using and when the user clicks the button to add a new row I would then toggle visibility of one of the hidden record sets. This is a sloppy solution and I dont like it. Is there any other method of doing what I am trying to do?
RE: dynamic subrecord sets
You should be able to achieve what you are describing using an Editable Row control and Data-driven design using RDBMS as your design source. Use the Editable Table Row control within the Rich Composite Controls palette. You can locate the SQL Data Source within the Data Sources tab, alongside the design palettes.
Search for 'Editable Row' and 'Editable Table' on this Forum.
http://www.hyfinity.com/node/264
You can learn more about designing pages using SQL tables by following these links:
http://www.hyfinity.com/node/64
http://www.hyfinity.net/mvcdocumentation/index.html?page=RuleMaker%20User%20Guide_SQL%20Statement
Search for 'SQL Statement' on the forum and also within the online WebMaker documentation.
Regards
Abdul
RE: dynamic subrecord sets
How do you convert a repeating table that webmaker automatically generates when you drag from the sql data source over a record set with the "edit multiple rows" option selected?
I tried re-creating all the elements that are generated when I drag over the non data bound editable row widget from the pallet, including the javascript snippet, but that did not generate the editable table controls. I had to manually set all the data bindings for the editable row widget for it to function as I desired.
RE: dynamic subrecord sets
You can drag and drop your Editable Row on the canvas first. Then select your database table on the Data Sources tab and drag and drop the repeating SQL data structure over the repeating element of the Editable Row. This is a general 'merge' operation which WebMaker provides and indicated by a bounding border and/or cross-hairs when you hover over the target control on the canvas. WebMaker should do the rest.
Hope it works for you.
Kind Regards
Abdul
RE: dynamic subrecord sets
1-up from that: How can I make sure the user has entered at least one record that has a specific type (my editable row table has a text box and a dropdown, the type is in the dropdown)?
RE: dynamic subrecord sets
/** * @param et Name of your Editable Table */ function singleRecTypeValidation(et) { //Retrieve the Editable Table record count alert(hyf.editabletable.manageCount(dojo.byId(et), "get")); //Your validation requirements here... //Search for controls with the class 'select' within the editable table. //If you have multiple selects then you can filter them in the next step using appropriate JS or Dojo helpers. dojo.query("select", dojo.byId(et)).forEach(function(selectNode){ //Don't count the new record select entry type if(!selectNode.name.startsWith(et + "BlankEntry")) { alert(selectNode.id); //I assume the following is your record type alert(selectNode.value); //Your validation requirements here... } }); }
You can invoke your script in conjuction with WebMaker's standard validation sequencing. Search for 'custom validation' on the WebMaker Forum and the online Documentation.
http://www.hyfinity.com/node/82
http://www.hyfinity.com/node/81
Regards
Abdul