I am creating a form builder and I want to create a form with two columns based on given JSON data. The issue is that my method decides on runtime which form item (like TextRow, NameRow etc) is to be rendered so I need to provide some base class/interface to SplitView like in the following way:
SplitRow<BaseRow,BaseRow>(){
$0.rowLeft = getFormField(fieldToRender: "Text Area") as? TextAreaRow // getFormField decides on runtime which type of field to render i.e TextRow and returns BaseRow type.
$0.rowRight = getFormField(fieldToRender: "Text Row") as? TextRow
}
But the above code gives the following error:-
Type 'BaseRow' does not conform to protocol 'RowType'
I want that somehow I can give a base class to Split row so it can infer class (form item) at runtime as Eureka does, if I pass BaseRow to Eurekas <<< operator it dynamically renders the field base on given sub class. Following is Eureka's example that accepts BaseRow class and renders given form filed, TextRow or PickerInputRow or any other class:
I am creating a form builder and I want to create a form with two columns based on given JSON data. The issue is that my method decides on runtime which form item (like TextRow, NameRow etc) is to be rendered so I need to provide some base class/interface to SplitView like in the following way:
But the above code gives the following error:- Type 'BaseRow' does not conform to protocol 'RowType'
I want that somehow I can give a base class to Split row so it can infer class (form item) at runtime as Eureka does, if I pass BaseRow to Eurekas <<< operator it dynamically renders the field base on given sub class. Following is Eureka's example that accepts BaseRow class and renders given form filed, TextRow or PickerInputRow or any other class:
form.last! <<< getFormField(fieldToRender: "Text Field")
For refrence i have added getFormField() method:-