A custom model is a model that's isn't implemented in your datamodel. It is used to store sets of data in a object instead of using multiple loose variables. You can find all your custom models via Tools > Custom models. Custom models come in two shapes.

  1. Based on a webservice response.
  2. Based on an existing model (derived).

Webservice custom models.

When you're testing your webservice you can create a custom model containing all the data from the response with only one click on the button.

The custom model button can be found when testing a JSON webservice

When you click 'Generate custom model', one custom model will be created, based on the whole response. The custom model properties try to find their own type, which may even be another custom model. You're able to edit these types if you don't agree with the given type.
 This is the custom model of the first picture:

The custom model result

This custom model can now be used in actions. It makes building a webservices a lot quicker because you won't have fetch every single variable using text expressions, which is also very much prone to error.

Derived custom models

Derived custom models are custom models based on (derived from) existing models from your datamodel.

Derived custom models can be created as input variables, and can come in handy when building form-pages with mutiple inputfields.

Let's say you've got a registration form for your contacts and you've got a Contact model with the properties firstname, lastname email, address, zipcode and city. You'll create a registration page which will look something like this:

This example comes from a template, also available for you!

POST page

When creating your POST page, you're able to capture all fields in one single input variable, a custom model.

If you don't know what form-pages and POST page are, make sure to read What are GET & POST pages or HowTo create a form page.

If you go to your POST page and add a new input variable, you can choose a custom model as a type. After you've selected custom model, and select a new custom model, you can select a model to base your custom model on. When you've chosen this and click 'Save' the variable browser will pop up.
 Here you can choose all variables which you want to use. In our case these were name, email, address, zipcode and city.

When you've selected your properties and saved the POST page, you can access your custom_model as an object in your action!

GET page

It's important to give the inputs in your GET page the proper names.
 The syntax for this is custom_modelname[propertyname].

So when you've got a custom model, based on your Contact model, named cm_contact and you've named the model's property first_name, your input-tag will have to look something like <input type="text" name="cm_contact[first_name]">

This is how you can use custom models

With custom models you can accelerate your building speed en decrease probability of making a mistake.

Did this answer your question?