Editor Select2 Multiple, Error: Array to string conversion in Query.php
Editor Select2 Multiple, Error: Array to string conversion in Query.php
vincmeister
Posts: 136Questions: 36Answers: 4
Hello Allan,
I want to allow multiple
on editor's field by using this example
There is an submit error on nik
field. this is the multiple value's field
<b>Notice</b>: Array to string conversion in <b>\php\Database\Driver\Mysql\Query.php</b> on line <b>93</b><br />
{"data":[{"DT_RowId":"row_305","emp_activity":{"nik":"Array","effective_date":"11 Jul 2016","leaves_category":"5","reason":"IDUL FITRI","submitted_by":"3","submitted_date":"2016-06-10 15:40:49"},"master_employee":{"full_name":null},"emp_activity_cat":{"emp_activity_category":"CUTI"}}]}
Debug
Please advise, thank you
danny
This question has accepted answers - jump to:
This discussion has been closed.
Answers
If you use
multiple
for Select2 then it will submit an array. It sounds like your server-side script is expecting a string. You could use theimplode
formatter to convert from array to string. Also make sure you useexplode
for the get formatter.Allan
thanks for the explanation Allan. Is there any example?
I'm trying to read this doc, but still confuse how to put the
implode
danny
There are examples of how to use the formatters on the formatter documentation page I linked to. For example you might use something like:
Assuming you want to store it in a single text field in your database of course.
Allan
hello Allan,
thank you for the example. Unfortunately, only the last value of my ```select2`` that stored to database.
Let's say i have 4
fields
, 1 of them usingselect2
when user input 3 values on 1st field, what i want is the editor submit 3 rows to mysql
what i got from this code below is only last value of the 1st field that submitted to mysql. please help again, thank you
here's my php file
<?php > ``` ?>```php
<?php
// DataTables PHP library
include( "../php/DataTables.php" );
Sorry - that is not something that Editor does. It will submit a single row only for each row that was edited or created. If you need to break the submitted data out into three rows you would need to use some custom code on the server-side - the pre-built PHP libraries will not provide that functionality.
Allan
OK Allan, thank you for the explanation
Feature requests maybe :)
To be honest it is unlikely the pre-built libraries will ever support such an action, but it is something I have added to the "blue sky" list.
Allan