HTML Elements Forums Forms & Editors Buttons How to custom the submit function of a form

This topic contains 4 replies, has 2 voices, and was last updated by Avatar yb 2 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #100966
    Avatar
    yb
    Participant

    I don’t want to post when I submit , I want to use my custom function inside  my component when I used:
    <div>
    <div><smart-form-control</div>
    <div>        align=”right”</div>
    <div>        control-type=”submit”</div>
    <div>        label=”Submit”</div>
    <div>        class=”primary”</div>
    <div>      ></smart-form-control></div>
    </div>
    There is a possibility to do something like that:
    <div>
    <div><smart-form-control</div>
    <div>        align=”right”</div>
    <div>        control-type=”submit”</div>
    <div>        label=”Submit”</div>
    <div>
    <div>
    <div>        (click)=”submit()”</div>
    </div>
    </div>
    <div>        class=”primary”</div>
    <div>      ></smart-form-control></div>
    </div>

    #100967
    Avatar
    admin
    Keymaster

    Hi yb,

    If you do not define a submit button in your Form, you can manually submit it by calling form.submit();

    Hope this helps.

    Best regards,
    Peter Stoev

    Smart HTML Elements
    https://www.htmlelements.com/

    #100969
    Avatar
    yb
    Participant

    I wanted to use the button of the library and specify with function to call something likee that:

    <smart-form-control  align="right" control-type="button" label="Submit"  class="primary" (click)="myFunc($event)"></smart-form-control>

    #100977
    Avatar
    admin
    Keymaster

    Hi yb,

    You can create the Form like that: https://www.htmlelements.com/angular/demos/form/template/ by using the same initialization process like in Angular Reactive Forms. Then you might not set the button’s ‘action’ property so your button will not submit the Form.

    Another possible solution is to use Angular Reactive Forms directly. Our Angular components are integrated with Angular Reactive Forms and also with the Template Driven Forms so you have options here. An example of such integration is: https://www.htmlelements.com/angular/demos/dropdownlist/reactiveforms/.

    Best regards,
    Peter Stoev

    Smart HTML Elements
    https://www.htmlelements.com/

    #100982
    Avatar
    yb
    Participant

    ok thanks

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.