How to use in reactive form count of items in Picklist in PrimeNg

Discussão em 'Angular' iniciado por New Folder, Janeiro 14, 2025.

  1. New Folder

    New Folder Guest

    I have a reactive that user need to fill up and in addition to that user need to select topics that we want to be assigned for. Everything is ok when I create a new user, but when I use the same form to update the user information, but I only want to change list of topics my "Create/Update" button stays disabled.

    I can't find out how I can use selectedTopics that would allow me to incorporate into myForm and would mark the form dirty.

    html code:

    ...
    <p-pickList class="w-full" [source]="topics" [target]="selectedTopics" sourceHeader="Available" targetHeader="Selected" [dragdrop]="true" [responsive]="true" [sourceStyle]="{ height: '30rem' }" [targetStyle]="{ height: '30rem' }" breakpoint="1400px" filterBy="name" sourceFilterPlaceholder="Search by name" targetFilterPlaceholder="Search by name" [showSourceControls]="false">
    <ng-template let-topics pTemplate="topic">
    <div class="flex flex-wrap align-items-center gap-3">
    <div class="flex-1 flex flex-column gap-2">
    <span class="font-bold">{{ topic.name }}</span>
    </div>
    </div>
    </ng-template>
    </p-pickList>
    ...
    <div class="flex justify-content-end gap-2">
    <p-button label="Cancel" severity="secondary" styleClass="p-button-secondary" (onClick)="cancel()" />
    <p-button label="Create/Update" (onClick)="onSubmit()"
    [disabled]="myForm.invalid || !myForm.dirty" />
    </div>


    I looked over the primeng documentation and can't find any information how they suggest to use picklist together with reactive form.

    Continue reading...

Compartilhe esta Página