Alert with Input Text and Radio Button

hi everyone
this is my code

this.intervention.getrequest("CRM_ArticleList?type=JUSTIF").then(data => {
      this.dataa = data;
      console.log('dataa=',this.dataa.results[0].libArt)
      this._isloaded = true;
    }).catch(err => {
      this._isloaded = true;
      let alert = this.alertCtrl.create({
        title: 'Erreur',
        subTitle: 'Erreur de connexion',
        buttons: ['OK']
      });
      alert.present();
    })
  
  let alert = this.alertCtrl.create ();
  alert.setTitle ('Justif');
  for (let i = 0; i <this.dataa.results.length; i++) {
    alert.addInput ({
      type: 'radio',
      label: this.dataa.results[i].libArt,
      value: this.dataa.results[i].libArt ,
      checked: false
    });
  }
  
  alert.addInput({
    type:'text',
    label:'Surname',
    placeholder: 'Surname'
  });
  
  alert.addButton ('Annuler');
  alert.addButton ({
    text: 'Enregistrer',
    handler: data => {
      this.composent.toastShow("Enregistré avec succés", false, "bottom");
  }

  });
  alert.present ();

but like you see i have problem with text input


can anyone help me and thnx :grin: :sweat_smile:

I didn’t found any addInput method in the ion-alert documentation. But I see that the input field is defined this way:

const alert = await this.alertController.create({
  inputs: [
    {
      name: 'name1',
      type: 'text'
    },

I suggest you to try this way:

alert.addInput({
	inputs: [
		type:'text',
    	        label:'Surname',
    	        placeholder: 'Surname'
	]    
  });
1 Like

thank’s for your help i found the problem with alert.addInput, it cannot mix input types

How To Add radio button in ionic alert ::

  async presentAlertLanguage() {

    var options = {
      inputs: [],
      header:"languages",
      buttons: [
        {
          text: 'cancle',
          role: 'cancel',
          handler: () => {
            console.log('Cancel clicked');
          }
        },
        {
          text: 'ok',
          handler: (data) => {
               //do something 
          }
        }
      ]
    };
    // add options here 
    options.inputs = [];
    for (let index = 0; index < this.languages_active.length; index++) {
      options.inputs.push({ name: 'options' + index, value: this.languages_active[index], label: this.languages_active[index], type: 'radio' })
    }

    const alert = await this.alertController.create(options);
    alert.present();
  }

this code will be something like this