Array to string conversion error, help wanted


#1

hi there im pretty new to ionic and i am almost done completing my first fullfledged app but i am still getting 1 bug. since it was an error display that i have never seen before i was wondering if someone could help me with this.

html:


<ion-content padding>
  
    <div class="form-group"  name="editForm"> 
      <form #f="ngForm"  >
        
            <label>naam:</label> <br><br>
            <input type="text" [(ngModel)]="question.name" name="name"  ><br><hr>
        
            <input type="hidden" [(ngModel)]="question.module_id" name="module_id">

            <label>volgorde:</label> <br><br>
            <input type='number' [(ngModel)]="question.order"  name="order"  >
            
            <hr>
            <ion-item>
              <ion-label>mag terug?</ion-label>
              <ion-toggle name="draftToggle" [(ngModel)]="question.can_go_back" checked="{{question.can_go_back}}"  ></ion-toggle>
            </ion-item><br>
 
            <label for="question.module_id" >pagina type: </label><br><br>
            <select name="singleSelect"  class="styled-select semi-square" [(ngModel)]="question.question_type_id">
                  <option [ngValue]="1">intro</option>
                  <option [ngValue]="2">media</option>
                  <option [ngValue]="3">enkele vraag</option>
                  <option [ngValue]="4">multiplechoice</option>
                  <option [ngValue]="5">open vraag</option>
                  <option [ngValue]="6">resultaat</option>
                  <option [ngValue]="7">weel of fortune</option>
                  <option [ngValue]="8">formulier</option>
            </select><hr>

            <ion-item>
              <ion-label>opslaan als draft?</ion-label>
              <ion-toggle name="draftToggle" [(ngModel)]="question.draft" checked="{{question.draft}}" >
</iontoggle>
            </ion-item><br>
            <input type="button"   value="opslaan" class="btn btn-primary" (click)=submit(question.id)>
        </form>
      </div>
  </ion-content>

functions:

export class EditPagePage {
  public question_id = this.question_id;
  public loading: boolean = true;
  public questionsReq: QuestionsRequest[] = [];
  public question: Question = new Question();
  public arQuest: Questions = new Questions();
  

  constructor(public navCtrl: NavController, public navParams: NavParams, public questionprovider: QuestionsProvider, public alertControler: AlertController, ) {

    this.question_id = navParams.get("id");
    console.log("id: " + this.question_id)

    questionprovider.get(this.question_id)
      .subscribe(res => {
        // User has access to all labels
        this.question = res;
        console.log(res.name)
        this.loading = false;
      });
  }


  public submit() {
   
    this.questionprovider.edit(this.question )
      .subscribe(res => {
        // Disable loading
        console.log(this.question.id)
      }, err => {

        this.loading = false;
        let alert = this.alertControler.create({
          title: "kan niet opslaan",
          message: "een of meerderen velden zijn niet goed ingevult.",
          buttons: [
            {
              text: "Terug"
            }
          ]
        });
        alert.present();
      });
  }

}

provider:

  public answer: Answer = new Answer();
  public Answer: AnswersRequest[] = [];

 public editAnswer(answer) {
    
    return this.http.put<AnswersRequest>("answer/" + answer.id, answer);
  }

i think this is the code that kills my request:

  * Replace the first occurrence of a given value in the string.
     *
     * @param  string  $search
     * @param  string  $replace
     * @param  string  $subject
     * @return string
     */
    public static function replaceFirst($search, $replace, $subject)
    {
        if ($search == '') {
            return $subject;
        }

        $position = strpos($subject, $search);

        if ($position !== false) {
            return substr_replace($subject, $replace, $position, strlen($search));
        }

        return $subject;
    }

and the data that i try to send


1. answers: []
2. can_go_back: 0
3. contents: [{id: 1, title: null, description: null,…},…]
4. created_at: null
5. deleted_at: null
6. id: 1
7. module_id: 1
8. name: "Intro"
9. no_check: 0
10. order: 1
11. question_type_id: 1
12. time_limit: null
13. updated_at: null

#2

I’m not seeing where you’re calling this potentially problematic function. Can you show that?


#3

it was an fault im my api fixed it by loading all valuesof the on there using $fillable