No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    [Vue warn]: Invalid prop: type check failed for prop "value". Expected Boolean, Array, got String.

    Help
    2
    7
    10370
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ssuess
      ssuess last edited by

      When using q-checkbox, I get the above error when outputting the value from the db, which will be a string of 0 or 1. How can I change this so I don’t get the above error?

      Here is my code that results in the error above, it is part of a loop that prints values from my array:

      <tr v-if="post.meta_key === 'ma_share'"><td class="labels">SHARING:</td><td class="values">
      <q-checkbox
        v-model="post.meta_value"
        v-bind:true-value="1"
        v-bind:false-value="0"
      />  </td><td></td></tr>
      

      If I use the standard vue checkbox, it works without any error:

      <tr v-if="post.meta_key === 'ma_share'"><td class="labels">SHARING:</td><td class="values"><input
        type="checkbox"
        v-model="post.meta_value"
        v-bind:true-value="1"
        v-bind:false-value="0"
      > </td><td></td></tr>
      
      1 Reply Last reply Reply Quote 0
      • ssuess
        ssuess last edited by

        FYI I have tried it both with and without the v-bind attributes…

        1 Reply Last reply Reply Quote 0
        • rstoenescu
          rstoenescu Admin last edited by

          There are no true-value and false-value props. Model needs to be a Boolean OR an Array of Strings (current ‘selected’ values) along with val prop. You could transform the data you get from server to be a Boolean.

          What you want with the two new props would be a new request.

          1 Reply Last reply Reply Quote 0
          • ssuess
            ssuess last edited by

            my data is a 0 or a 1, and I have now changed my API to not quote the numbers, but I am still getting an error. Are you saying I can’t have a 0 or 1, I have to send “true” or “false”?

            1 Reply Last reply Reply Quote 0
            • ssuess
              ssuess last edited by

              I have tried things like this, but they don’t work:

              <q-checkbox
                v-model="Boolean(post.meta_value)"
              />
              
              1 Reply Last reply Reply Quote 0
              • ssuess
                ssuess last edited by

                Ok, I have my API returning “true” and “false” and it STILL doesn’t work. It is back to the same error. Any suggestions?

                1 Reply Last reply Reply Quote 0
                • ssuess
                  ssuess last edited by

                  I ended up having to rewrite my API (in php) to deal with 1 and 0 in the db to make it work for this component. In case anyone is wondering, here is what it looked like:

                  $myarrayeverythingbutbooleans = firstsql
                  $justbooleans = booleansonlysql
                  $jbtotalarray = array();
                  foreach ($justbooleans as $jbpush) {
                  if (($jbpush['meta_value']=="1")) {
                  $jbpush['meta_value'] = true;
                  } else {
                  $jbpush['meta_value'] = false;
                  }
                  $jbtotalarray[] =  $jbpush;
                  }
                  $mergedwithtrue = array_merge($myarrayeverythingbutbooleans,$jbtotalarray);
                  
                  return $mergedwithtrue;
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post