angular-form-gen icon indicating copy to clipboard operation
angular-form-gen copied to clipboard

Would it be possible to create composite inputs?

Open JoeGrasso opened this issue 10 years ago • 3 comments

How could I go about creating a "quick input", for example "FullName", that if the user dragged it over there would be two text boxes, one for first and last name?

JoeGrasso avatar Feb 23 '15 15:02 JoeGrasso

You can register custom field templates. I haven't documented this yet, but something like this should do the trick:

app.config(function (fgConfigProvider, FgField) {

  var category = 'Text input fields';
  var fieldTemplate = new FgField('appDateInput', {
    displayName: 'Date',
  });

  var templateUrl = 'app/common/date-input/fg-field-date-input.ng.html';
  var propertiesUrl = 'app/common/date-input/fg-properties-date-input.ng.html';

  fgConfigProvider.fields.add(fieldTemplate, category, templateUrl, propertiesUrl);

  fgConfigProvider.validation.message({
    date: 'Invalid date',
    dateMin: 'Date value too low',
    dateMax: 'Date value too high'
  });

});

Each field requires two templates:

  1. Default: Used when the field is rendered in the form
  2. Properties: Used when the properties are displayed in the editor.

Have a look at the default templates for examples.

McNull avatar Feb 23 '15 17:02 McNull

You answer does not demonstrate how to have a field template with two fields in it. ie First Name and Last Name. Would be helpful if you could elaborate, please. As much as I can see your answer is referring to what we do normally when adding a single custom field, and so you have not answered the question about "composite fields" . Apologies if I have missed the point of your comment. :)

markeaston avatar Aug 14 '16 20:08 markeaston

I did manage to work out how to do it. I ended up wit a field template with two fields in it so that they were combined in the form designer. But then we needed another separate field in the schema - so I manually inserted that on server side. But then I needed a field in Formgen to support this inserted field so I create a second field template for the second field which was empty - so it did not render anything to the field.

markeaston avatar Aug 18 '16 19:08 markeaston