How to fill a field value from the server side (newbie)
How to fill a field value from the server side (newbie)
luisrortega
Posts: 79Questions: 6Answers: 1
Hi,
I have a table that during insertion I'll like to set a field (from the server side). Be aware that the client side it's not aware at all of this value.
[code]
$editor = Editor::inst( $db, 'completiontypes' )
->field(
Field::inst( 'id' )->set( false ),
Field::inst( 'name' )->validator( 'Validate::required' ),
Field::inst( 'company')// <--- this field needs to populated with a value stored on the server side
);
[/code]
I have a table that during insertion I'll like to set a field (from the server side). Be aware that the client side it's not aware at all of this value.
[code]
$editor = Editor::inst( $db, 'completiontypes' )
->field(
Field::inst( 'id' )->set( false ),
Field::inst( 'name' )->validator( 'Validate::required' ),
Field::inst( 'company')// <--- this field needs to populated with a value stored on the server side
);
[/code]
This discussion has been closed.
Replies
[code]
if ( isset( $_POST['action'] ) && $_POST['action'] === 'create' ) {
$_POST['data']['company'] = 'myValue';
}
[/code]
drop that in before the Editor PHP instance is initialised and the data that it processes will then have the value needed. If you don't want to manipulate the _POST array (probably a good idea not to), just copy it to a new array (i.e. `$data = $_POST` ) beforehand.
Regards,
Allan