Connected record required on form submit

I have a multi step form which adds a Law Office. With some connected records. The main record is a Law Office, with Lawyers as the connected record... I have a Page with a table, which contains the Lawyers for that Law Office so they can be viewed/edited, and Add Menu item for them to add Lawyers, and then a form to update some other fields in the Law Office records..

I want to make sure that there is at least one Lawyer record for the Law Office when the submit button is pressed. Any suggestions on how to do this?


Yes you are thinking about it correctly.. As for the Knack.models, I have yet to see good documentation on any of that.. It's been trial and error and looking through all the code found on this site...

Julian - In this case I have a multi step form, so the Law Office record has already been created in an earlier step.. What I'm doing is preventing them moving on to the next step of the process, until they have at least one Lawyer in the table..

Julian - a question (I'm just curious):

Surely you have to have created the Law Office (submitted it) before you would be able to create any connected Lawyers?

If so, how can you prevent the Law Office from being created if there are no lawyers?

This helps.

I'm assuming that the table in scene_6 is the Lawyers table and is connected to the Law Office table. So if it's "empty", it really means there are no Lawyers associated with the connected Law office. Am I thinking about this correctly?

Also, where can I find documentation on Knack.models? I'm new to Knack and I'm trying to gather my resources.


var data_view_125 = Knack.models['view_125'].data.toJSON();

This grabs all the records that are found in the view_125 and drops them into data_view_125.. In my case view_125 is the table I have in the scene_6 that I want to make sure has at least one record in it.. So, by grabbing all the records from the table into data_view_125, and then seeing if it has a length greater than 0, tells me if there is at least one record.. Does that help?

I need to do something similar.

In the section "var data_view_125 = Knack.models['view_125'].data.toJSON()", what does the 'view_125' reference?

So, I used java script to solve this by looking to see if any records exist in the table data..

$(document).on('knack-scene-render.scene_6', function(event, scene) {
$("#view_11 .kn-button").on("click", function() {
var data_view_125 = Knack.models['view_125'].data.toJSON();
if (data_view_125.length == 0) {
alert ("Need at least one Lawyer in Firm");
return false;