I followed the tutorial “Inserting Data in Main and Sub Table using App Connect Form Repeat” (https://community.wappler.io/t/inserting-data-in-main-and-sub-table-using-app-connect- form-repeat/41648) and when saving the data, Wappler returns an error in the console: Array to string conversion.
Did I miss some detail?
TABLE STRUCTURE:
Main Table whats_included:
whats_id - int (auto increment and unsigned)
whats_pct_id - int
whats_title - varchar
whats_create_at - datetime
whats_update_at - datetime
whats_status - int
Whats_included_contents SubTable:
id - int (auto increment and unsigned)
content - varchar
whats_included_id - int
This is the form code:
<form id="form1" is="dmx-serverconnect-form" method="post" action="/dmxConnect/api/Pacotes/eng/whats_insert.php">
<div class="row">
<legend class="col-form-label">Whats título</legend>
<div class="col">
<div class="form-group mb-3">
<label for="input1" class="form-label">Título</label>
<input type="text" class="form-control" id="input1" name="whats_title" aria-describedby="input1_help" placeholder="Digite o título" required="" data-msg-required="Campo obrigatório.">
<small id="input1_help" class="form-text text-muted">Your input is very valuable.</small>
</div>
</div>
<div class="col">
<div class="form-group mb-3">
<label for="inp_whats_pct_id" class="form-label">Pacote ID</label>
<input type="number" class="form-control" id="in_whats_pct_id" name="whats_pct_id" aria-describedby="in_whats_pct_id_help" placeholder="ID do pacote" required="">
<small id="in_whats_pct_id_help1" class="form-text text-muted">Your input is very valuable.</small>
</div>
</div>
</div>
<div class="row">
<legend class="col-form-label">Conteúdos:</legend>
<div is="dmx-form-repeat" id="formRepeat1" dmx-bind:items="1">
<div class="row">
<div class="col">
<input id="content_id" name="conteudo" type="text" class="form-control" placeholder="Digite o conteúdo">
</div>
<div class="col-4">
<button id="btn1" class="btn btn-danger" dmx-on:click="formRepeat1.remove()">Delete</button>
</div>
</div>
</div>
</div>
<button id="btn2" class="btn btn-info" dmx-on:click="formRepeat1.add()">Novo conteúdo</button>
<button id="btn3" class="btn btn-success" type="submit">Salvar dados</button>
</form>
This is the code in the console.
{code: 0, file: “C:\laragon\www\onneviagens_trilingue\dmxConnectLib\lib\db\Connection.php”, line: 141,…}
code
:
0
filet
:
“C:\laragon\www\onneviagens_trilingue\dmxConnectLib\lib\db\Connection.php”
line
:
141
message
:
“Array to string conversion”
trace
:
“#0 [internal function]: exception_error_handler(2, ‘Array to string…’, ‘C:\\laragon\\www\\…’, 141)\n#1 C :\laragon\www\onneviagens_trilingue\dmxConnectLib\lib\db\Connection.php(141): PDOStatement->bindParam(1, Array, 2)\n#2 C:\laragon\ www\onneviagens_trilingue\dmxConnectLib\modules\dbupdater.php(164): lib\db\Connection->execute(‘INSERT INTO `wh…’, Array, false, ‘whats_included_…’ )\n#3 C:\laragon\www\onneviagens_trilingue\dmxConnectLib\lib\App.php(204): modules\dbupdater->insert(Object(stdClass), ‘insert’, Array) \n#4 C:\laragon\www\onneviagens_trilingue\dmxConnectLib\lib\App.php(144): lib\App->execSteps(Object(stdClass))\n#5 C:\ \laragon\www\onneviagens_trilingue\dmxConnectLib\lib\App.php(133): lib\App->exec(Object(stdClass), false)\n#6 C:\laragon\www \onneviagens_trilingue\dmxConnectLib\lib\App.php(111): lib\App->exec(Object(stdClass))\n#7 C:\laragon\www\onneviagens_trilingue\dmxConnect\ \api\Packages\eng\whats_insert.php(8): lib\App->define(Object(stdClass))\n#8 {main}”