Store hidden data in DB
Store hidden data in DB
Hi, i m working with Server Side Editor and PHP sessions. All works great. Now i'm trying to store in the DB the session name, i want this to store the name of the person who modifies the DB.
In my DB's table there is a fiel name "modifiBy".
My question is: How can i add the $_SESSION['user'] to Editor and send it to the table in the DB? Thanks to all.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Absolutely this can be done - using the
Field->setValue()
method:Documentation for it is available here.
Allan
Thaks for the quick answer. Where should i place this code? In the main editor or in the dates.php?
$editor->field(
new Field( 'last_author' )
->setValue( $_SESSION['user_id'] )
);
Thaks
I would suggest just adding the
->setValue()
chaining method to wherever you currently define the field that you want to set the value of.Allan
Allan sorry i don't understand where to place the code. i post my code. I want to send the session user to de data base. But i don't want to show this field in the table or in the editor, only send it to the Data Base.
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
}
editor.field( 'importe' ).input().on( 'keyup', multiply );
editor.field( 'IVA' ).input().on( 'click', multiply );
// Activate the bubble editor on click of a table cell
$('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
editor.bubble( this );
} );
],
"footerCallback": function( thead, data, start, end, display ) {
$(thead).find('th').eq(0).css({"background-color":"#C8ECA9"})
},
"footerCallback": function( tfoot, data, start, end, display ) {
$(tfoot).find('th').eq(0).html("");
$(tfoot).find('th').eq(1).html("");
$(tfoot).find('th').eq(2).html("");
$(tfoot).find('th').eq(3).html("");
$(tfoot).find('th').eq(4).html("");
$(tfoot).find('th').eq(5).html("");
$(tfoot).find('th').eq(6).html("");
$(tfoot).find('th').eq(7).html("");
$(tfoot).find('th').eq(8).html("");
$(tfoot).find('th').eq(9).html("");
},
} );
Allan, problem solved. i add i line in the dates.php.
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'ventas_2015' )
->fields(
Field::inst( 'empresa' ),
Field::inst( 'tipo_trabajo' ),
Field::inst( 'detalle_trabajo' ),
Field::inst( 'factura' ),
Field::inst( 'IVA' ),
Field::inst( 'importe_total' ),
Field::inst( 'fecha_venta' )
->validator( 'Validate::dateFormat', array(
"empty" => false,
"format" => Format::DATE_ISO_8601,
"message" => "Please enter a date in the format yyyy-mm-dd"
) )
->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601),
Field::inst( 'vendedor' ),
Field::inst( 'comentarios' ),
Field::inst( 'modificadox')->setValue( $usuario )
Sorry and thanks for all