Search code examples
cssangularjsionic-frameworkangular-schema-form

How to style form element in the angular-schema-form schema and not the form?


I am building a form using the awesome angular-schema-form. I am able to create my form schema object quite successfully. I am wanting (hoping) to be able to set all the form components in the schema using the x-schema-form property in the schema object.

I am able to specify the type and the titleMap's for selects all perfectly. However where I am having an issue is assigning a style to the element using the "x-schema-form" - it just seems to be being ignored.

So when I do the following (Note I have the Ionic Framework)

   "x-schema-form": {
      "type": "textarea",
      "style": "item item-input"
   }

The "style" is not getting passed to the form. If I pass the style in the $scope.form [] then I get the style. I am however trying to do this all in the schema as it would be much easier for me to do it in one place due to the nature in which I get the list of form elements.

Any advice on this would be greatly appreciated.

Thanks BrentR


Solution

  • so asf doesn't actually support the style attribute at all, so what you're trying there is not possible at the moment. However you can use x-schema-form to apply a fieldHtmlClass and then via CSS apply styling.

    You can read more on the standard options in the documentation. https://github.com/Textalk/angular-schema-form/blob/master/docs/index.md#standard-options