checkboxes value gets stored as "array"

checkboxes value gets stored as "array"

ViktorAlmViktorAlm Posts: 8Questions: 0Answers: 0
edited January 2013 in Editor
Hey and thank you for this awesome tool.

It's been working great until I added checkboxes in the fields. The column "sok" wich I changed from being a select gets the value "Array" in the mysql db. I dont remember when i downloaded the files but the .js says its version 1.22.

this is my response in firebug when posting my edit
[quote]

Notice: Array to string conversion in dataTables/php/lib/Database/Driver/Mysql/Query.php on line 78

{"id":"row_6","error":"","fieldErrors":[],"data":[],"row":{"DT_RowId":"row_6","process":"Verksamhetsstyrning","handling":"wertwer","sok":"Array","lagringsplats":"Dokumenthanteringssystem","bevaras":"7 \u00e5r","kommentar":"ererwt"}}[/quote]

with this as post data

[quote]action edit
data[bevaras] 7 år
data[handling] wertwer
data[kommentar] ererwt
data[lagringsplats] Dokumenthanteringssystem
data[process] Verksamhetsstyrning
data[sok][] Upphandlingsnummer
data[sok][] Fastighetsbeteckning
id row_6
table [/quote]

the last line in this code gets the error
[code]protected function _prepare( $sql )
{
$this->_stmt = $this->_dbcon->prepare( $sql );

// bind values
for ( $i=0 ; $i_value) ; $i++ ) {
//echo 'Binding: {:'.$this->_field[$i] .'} as {'. $this->_value[$i]."}\n";
$this->_stmt->bindValue( ':'.$this->_field[$i], $this->_value[$i] );[/code]

Does anyone have an idea what my problem might be?

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Absolutely - Checkboxes are treated as arrays by default to make it easier to work with joins (multiple SQL tables), but that's not so useful if you want to store the options selected in a single text field. For that there is the `separator` option of the `checkbox` field:
    http://editor.datatables.net/fields/#checkbox

    Regards,
    Allan
  • ViktorAlmViktorAlm Posts: 8Questions: 0Answers: 0
    Thanks!

    If someone else who's not that great at coding finds this on google, just add
    [code]"separator": "|"[/code]
This discussion has been closed.