1x ion-radio with 2 values


#1

Hi Ionic lovers! I’m creating an app for my bachelor semester project in Ionic, and I need a radio button that sends both values: “helper?.userId” and “helper?.fullName” - both of them work if there’s only one, but if both are there it won’t work. Does anybody have a solution?

Here’s a snippet of my code:

                        <ion-item mode="md" class="calendarTransparentTwo" *ngFor="let helper of helperList">
                            <ion-label mode="md">{{helper?.fullName}}</ion-label>
                            <ion-radio mode="md" color="lwhite" value="{{helper?.userId}}"></ion-radio>
                            <!--<ion-radio color="lwhite" value="{{helper?.fullName}}"></ion-radio> -->
                        </ion-item>

#2

Very confusing question. It doesn’t make sense to have two radio buttons in a single item, or to have a single radio button have two values. Can you just have the value be helper?


#3

I actually got it to work. Here’s what I did

var splitString = this.radioForm.assign.split(/_/);

then splitString[0] was the user id and splitString[1]was the full name

I’m still fairly new at coding so there is probably a much better way at doing this. But this worked for me, so I’m happy :slight_smile:


#4

Can we try to solve this properly? Please show us the whole form and backing component.


#5

I learned that I should just send $helper,helper with it instead to do it correctly. :slight_smile: