Select missing, Submit -> System Error
Select missing, Submit -> System Error
Hi Allan,
I have now a problem with the select field, since I split in the fields name and data, because names in Tags that contain a point in the name are not allowed. (ltv_events.m_city). I insert in the fields the data:
The modals open without any error. After I tried to insert a new line or editing an exist line the Select fields missed the options. if you click send the following error would I receive:
<b>Fatal error</b>: Uncaught Error: Call to a member function insertId() on null in C:\xampp7\htdocs\finswimming\assets\plugins\DTables\Editor\1.5.6\php\Editor\Editor.php:1380
Stack trace:
#0 C:\xampp7\htdocs\finswimming\assets\plugins\DTables\Editor\1.5.6\php\Editor\Editor.php(833): DataTables\Editor->_insert_or_update(NULL, Array)
#1 C:\xampp7\htdocs\finswimming\assets\plugins\DTables\Editor\1.5.6\php\Editor\Editor.php(588): DataTables\Editor->_insert(Array)
#2 C:\xampp7\htdocs\finswimming\assets\lib\evm_server_processing.php(96): DataTables\Editor->process(Array)
#3 {main}
thrown in <b>C:\xampp7\htdocs\finswimming\assets\plugins\DTables\Editor\1.5.6\php\Editor\Editor.php</b> on line <b>1380</b>
I think the reason is the missing options in the select field. Did you know where my problem is? I think it should work, because the JSON send the Options for the select field.
Hmm is see now, the will nothing do. No fields are stored in the Database.
Andreas
edit_mlist = new $.fn.dataTable.Editor({
ajax: 'assets/lib/evm_server_processing.php',
table: '#meetlist',
display: 'bootstrap',
fields: [{
label: 'Event Title:',
name: 'm_title',
data: 'ltv_events.m_title'
},{
type: 'datetime',
label: 'Start Date:',
name: 'b_date',
data: 'ltv_events.b_date',
def: function () { return new Date(); },
format: 'DD. MMMM YYYY'
},{
type: 'datetime',
label: 'End Date:',
name: 'e_date',
data: 'ltv_events.e_date',
def: '',
format: 'DD. MMMM YYYY'
},{
type: 'datetime',
label: 'Deadline:',
name: 'deadline',
data: 'ltv_events.deadline',
def: function () { return new Date(); },
format: 'DD. MMMM YYYY'
},{
label: 'Course:',
name: 'm_course',
data: 'ltv_events.m_course',
type: 'radio',
options: [ '50m', '25m'],
def: '50m',
fieldInfo: ''
},{
label: 'Street:',
name: 'm_street_1',
data: 'ltv_events.m_street_1'
},{
label: '',
name: 'm_street_2',
data: 'ltv_events.m_street_2'
},{
label: 'ZIP:',
name: 'm_zip',
data: 'ltv_events.m_zip'
},{
label: 'City:',
name: 'm_city',
data: 'ltv_events.m_city'
},{
label: 'Nation:',
name: 'm_nation',
data: 'ltv_events.m_nation',
type: 'select',
def: 'AUT'
}
]
});
Replies
Can you show me your PHP as well please?
Thanks,
Allan
```
if((include PLUGIN_DIR.'DTables/Editor/1.5.6/php/DataTables.php') == FALSE){ echo 'Failed include Edit'; }
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
$db->sql( 'CREATE TABLE IF NOT EXISTS
ltv_events
(id
INT UNSIGNED NOT NULL AUTO_INCREMENT ,federation
VARCHAR(255) NOT NULL,b_date
DATE NOT NULL ,e_date
DATE NOT NULL ,deadline
DATE NOT NULL ,m_title
VARCHAR(255) NOT NULL ,m_course
VARCHAR(5) NOT NULL ,m_street_1
VARCHAR(255) NOT NULL ,m_street_2
VARCHAR(255) NOT NULL ,m_zip
VARCHAR(10) NOT NULL ,m_city
VARCHAR(255) NOT NULL ,m_nation
VARCHAR(5) NOT NULL ,PRIMARY KEY (
id
))ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;' );
$FormattoSQL = 'd. F Y';
$SQLtoFormat = 'd. F Y';
Editor::inst( $db, 'ltv_events', 'id' )
<?php > ``` ?>->fields(
Field::inst( 'ltv_events.id' ),
Field::inst( 'ltv_events.b_date' )
->validator( 'Validate::dateFormat', array(
'empty' => false,
))
->getFormatter( function ($val, $data, $opts ){
if($val === '0000-00-00'){ return NULL; }
else{ return date( 'Y-m-d', strtotime( $val )); }
}
)
->setFormatter( 'Format::date_format_to_sql', $FormattoSQL ),
Field::inst( 'ltv_events.e_date' )
->validator( 'Validate::dateFormat', array(
'empty' => false,
'format' => $FormattoSQL,
))
->getFormatter( function ($val, $data, $opts ){
if($val === '0000-00-00'){ return NULL; }
else{ return date( 'd. F Y', strtotime( $val )); }
}
)
->setFormatter( 'Format::date_format_to_sql', $FormattoSQL ),
Field::inst('ltv_events.deadline')
->validator( 'Validate::dateFormat', array(
'format' => $FormattoSQL,
))
->getFormatter( function ($val, $data, $opts ){
if($val === '0000-00-00'){ return NULL; }
else{ return date( 'd. F Y', strtotime( $val )); }
}
)
->setFormatter( 'Format::date_format_to_sql', $FormattoSQL ),
Field::inst( 'ltv_events.m_title' )
->validator( 'Validate::minLen', 2 ),
Field::inst( 'ltv_events.m_course' )->validator( 'Validate::notEmpty' ),
Field::inst( 'ltv_events.m_street_1' ),
Field::inst( 'ltv_events.m_street_2' ),
Field::inst( 'ltv_events.m_zip' ),
Field::inst( 'ltv_events.m_city' ),
Field::inst( 'ltv_events.m_nation', 'm_nations' )
->options('nation_codes', 'IOC', 'name_en')
->validator( 'Validate::dbValues' ),
Field::inst( 'nation_codes.name_en' ),
Field::inst( 'nation_codes.ISO3166-1-Alpha-2 as ISO3166' ),
Field::inst( 'ltv_events.federation' ),
Field::inst( 'ltv_events.id', 'ltvid')
->getFormatter( function ($val, $data, $opts ){
return 'row_'.$val;
}
)
)
->leftJoin('nation_codes', 'nation_codes.IOC', '=', 'ltv_events.m_nation')
->process( $_POST )
->json();
I think
name: 'deadline',
should actually bename: 'ltv_events.deadline',
(i.e. matching what is in the PHP).The same applies to many of the other fields. In fact, I don't believe you need to use the
fields.data
option at all. Just setfields.name
to match the data from the PHP.Allan
The Problem is the css. I can not define a field class
div.DTE_Field_Name_ltv_event.m_street_2
in the css file, because all browser ignore or have an error, with this class name.To use a data attribute and a name attribute is a solution to solve the Problem, but it open the next problem to send the fields data to the server correct.
Andreas
There are various options to use CSS selectors for a class name with a dot in it - see this SO thread for example.
Allan
Thanks, with the attribute selector works the css and I can remove all
data
in thefields
Thanks Allan