Is it possible to use php db class with a plain text form ?
Is it possible to use php db class with a plain text form ?
Hi,
I want to design my form without using modal form.
When I submit with html form below I got error.
<form action="extraDao/htmlDao.php" method="post">
<input type="hidden" name="action" value="create">
<textarea class="form-control" name="data[0]['html']"></textarea>
<input type="submit" value="Save" class="form-control">
</form>
include( "../../libs/datatables/media/php/DataTables.php" );
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
Editor::inst( $db, 'html','Id' )
->fields(
Field::inst( 'html' )
)
->process( $_POST )
->json();
Server receive $_POST
Array
(
[action] => create
[data] => Array
(
[0] => Array
(
['html'] => test
)
)
)
Error I got
Fatal error: Call to a member function insertId() on null in C:\data\demo\application\test\libs\datatables\media\php\Editor\Editor.php on line 1381
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
That looks like it should probably work. What is the schema for your
html
database table please?Allan
CREATE TABLE
html
(Id
int(11) NOT NULL AUTO_INCREMENT,html
text,PRIMARY KEY (
Id
)) ENGINE=InnoDB DEFAULT CHARSET=utf8
Sorry, I missed an error.
After form submit, htmlDao.php got the following error.
Fatal error: Call to a member function insertId() on null in C:\data\demo\application\test\libs\datatables\media\php\Editor\Editor.php on line 1381
That error suggests that the insert failed.
Could you download the new Editor 1.6 and enable its new debugging mode by adding
->debug( true )
immediately prior to->fields(
?Then show me the JSON response from the server so I can see the queries and bound values.
Thanks,
Allan
Got the following error
http://debug.datatables.net/ikefox
That suggests that the client-side Javascript is using Editor 1.6.0, but the server-side PHP libraries are still an older version (1.5.6 perhaps). Could you update your PHP libraries for Editor as well please?
Allan
Hi,
I download php libraries again the ->debug error gone.
Demo url : http://cms.kineticspace.net/cmsBase/template/htmlForm.php
Login Id : allan
Password : 123456
Thanks! Could you try changing
data[0]['html']
to bedata[0][html]
?Allan
It works after single quote removed, thanks
Fantastic. Thanks for letting me know!
Allan