DynamicForm: Text Box and Select Box with Validation

Version: SmartGWT 2.4

I’m trying to create a form with a combination of text boxes and combo boxes. The examples for text boxes use DataSourceTextField, which are then added to the DataSource with dataSource.addField(dstf).

DataSource dataSource = new DataSource(); 
DataSourceTextField dsAddress1Field = new DataSourceTextField("address1");  
dsAddress1Field.setTitle("Address 1");    
dataSource.addField(dsAddress1Field);

When I look at the examples for combo/select boxes, I see that they use a different method for getting added to the display, calling form.setFields().

DynamicForm selectComboForm = new DynamicForm(); 
ComboBoxItem cbItem = new ComboBoxItem();

How do I mix and match text boxes with combo boxes in the same form, and how would I perform validation in this case?

Thanks!
Mike

You’re confusing DataSourceFields with FormItems. DynamicForms can be bound to a DataSource and, when bound, FormItems are created automatically according to the types of the DataSourceFields, or overrides you specify on each field.

You can also create and add FormItems directly, as in your second example.

Take a look at the Form examples in the showcase and read the data-binding overview and related docs.