How to display supplemental information on edit form
How to display supplemental information on edit form
I have 3 tables, a students table, a contacts table and a table that links the 2, relationships. When editing the relationships table I want to be able to display supplemental information such as student name and contact name but I can't find an example. My intention is to use a template to show the First and Last names of the student and the contact and have them appear as labels/text instead of a read-only input.
I am using .NET Core and here is the controller code that returns the Json:
Microsoft.AspNetCore.Http.HttpRequest request = HttpContext.Request;
using (var db = new Database(_DataTablesConfig.Value.DbType, _DataTablesConfig.Value.DbConnection))
{
var keys = new string[] { "StudentID", "ContactID" };
DtResponse response = new Editor(db, "StudentRelations", keys)
.Model<StudentRelations>("StudentRelations")
.Model<DTStudentInfo>("StudentInfo")
.Model<StudentContactInfo>("ContactInfo")
.Model<SchoolInfo>("SchoolInfo")
.LeftJoin("StudentInfo", "StudentInfo.StudentID", "=", "StudentRelations.StudentID")
.LeftJoin("SchoolInfo", "SchoolInfo.SchoolID", "=", "StudentInfo.SchoolID")
.LeftJoin("StudentContactInfo", "StudentContactInfo.ContactID", "=", "StudentRelations.ContactID")
.Process(request)
.Data();
return Json(response);
}
Thanks in advance
Answers
With Editor you can select the additional fields you want to show in the Editor form and they will be passed to the front end even though you don't use them as data entry fields in the form.
These fields you can then render yourself and display them as field().label() or as field().fieldInfo() or as field().labelInfo() or field().message()