Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #103263
    Rafa Esparza
    Participant

    Hi,
    i’m coding in angular and i using Smart.Form, creating the form controls and validations from .ts files. To add the entity values into form values. I’m doing the form = new Smart.form(…) when the data in the entity object is loaded. In the same view, if i load another entity, i recreate the form reasigning the value to the form again, but instead of removing the old form controls and reasign the new ones, the form controls and validators are nesting them.
    How should i do this ?
    Thanks, i attach an example of the code

    When entity is loaded i do this:

      ngOnchange(): void {
        const entity ....
        this.createForms();
        this.dataForm.value = entity;
      }
      
      createForms(): void {
        this.dataForm= new Smart.Form('#dataForm', {
          codivas: ['', {
            validationRules: [
              { type: 'required', message: 'El código es obligatorio.' },
            ]
          }]
       ........
       })
     }
    #103268
    admin
    Keymaster

    Hi Rafa,

    Thank you writing. It is currently not possible to re-create a form. After a form is created, you can set its value like form.value = some json object.

    Best regards,
    Peter Stoev

    jQWidgets Team
    https://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.