Add value in server side script

Add value in server side script

rainolfrainolf Posts: 56Questions: 6Answers: 0

Hello,
based on this example:

http://editor.datatables.net/examples/advanced/tableOnlyData.html

i'm trying to create a new record hiding a field in the form and then i would process the SQL insert with filled data + data passed in server side scrirpt.

Example:

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'users' )
->fields(
Field::inst( 'first_name' ),
Field::inst( 'last_name' ),
Field::inst( 'owner' )
->set( false )
->getFormatter( 'Format::date_sql_to_format', 'D, jS F Y' )
)
->process( $_POST )
->json();

Instead Formatter put my variable in some way:

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'users' )
->fields(
Field::inst( 'first_name' ),
Field::inst( 'last_name' ),
Field::inst( 'updated_date' )
which code to $_GET the variable???
)
->process( $_POST )
->json();

Thank you

Replies

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin

    I'm afraid I'm not understanding. You are sending both GET and POST data? That's okay, but I don't understand what you want to do with the extra value. Its an Editor field instance in your Javascript is it? If so, it is submitted as a normal field.

    Allan

  • rainolfrainolf Posts: 56Questions: 6Answers: 0

    Simply in my form i would omit one field.
    Right now i've 5 fields:
    Name
    Company
    email
    Description
    Owner

    I would like to omit "Owner" from form and pass to a query in server side retrieved by a $_Session variable already present in my php script.

    This will permit the user to fill only the first fields and the 5th will be automatically inserted.

    Hope i've clarified better

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    $_POST['data']['Owner'] = $_SESSION['Owner'];
    

    then then use _POST as before. If you would prefer not to modify _POST (possibly a good idea) just copy it to another variable.

    Allan

  • rainolfrainolf Posts: 56Questions: 6Answers: 0

    Sorry but its not clear for me.
    The behavior should e on create or edit actions.

    So could you post me an example in order to work on it?

    Thank you

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    if ( isset($_POST['action']) && ( $_POST['action'] === 'create' || $_POST['action'] === 'edit' ) ) {
       $_POST['data']['Owner'] = $_SESSION['Owner'];
    }
    

    Allan

  • rainolfrainolf Posts: 56Questions: 6Answers: 0

    Good...Thank you

This discussion has been closed.