I really need a little help

I really need a little help

miguelgomesmiguelgomes Posts: 2Questions: 1Answers: 0

Hello Allan and friends .... I really need a little help.

Presidential elections will take place in Brazil next month and I want to make a table - decision matrix - so that people can compare the candidates by criterias, rationally.

Each criterion is a line. Each column represents one of the candidates. Voters will give each candidate a grade on that criterion.
At the end the system presents the candidates with higher grades.

How do I make each voter only see and only edit the criteria and the notes that he created himself?
I figured I could create a field in each line with the session_id and then make a filter only showing the records
that user in that session. Or use a cookie for the same purpose.

I found some posts with the same problem that were later solved but has no indication of how they found the solution.

                   Field::inst( 'ses' )->setFormatter( function ( $val, $data, $opts ) {
                          return $_SESSION['$ses_id'];
                                                                  } )

This attempt gives the following error:
PHP Parse error: syntax error, unexpected 'Field' (T_STRING) in ... line 49

This:
$editor->field(new Field( 'userid' )
- ->setValue($_COOKIE['name']));

and this

                                     $editor->field(
                                                  new Field( 'last_author' )
                                         ->setValue( $_SESSION['user_id'] )
                                                        );

Shows the following error in the log
PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in ... on line 47

These are the posts that I referred to:
https://datatables.net/forums/discussion/33974
https://datatables.net/forums/discussion/comment/119919/#Comment_119919
https://datatables.net/forums/discussion/42828

My questions are:
how do I save the session id in each record?
how do I filter by these record´'s ids that are shown to the users?

thanks a lot....

Answers

  • allanallan Posts: 62,992Questions: 1Answers: 10,367 Site admin

    What version of PHP are you using? If 5.3, then you can't chain onto a new constructor. You need to use Field::inst( ... )->setValue() for example.

    Allan

  • miguelgomesmiguelgomes Posts: 2Questions: 1Answers: 0

    Hi Allan,
    Yes, 5.3,
    But the error persists
    PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in ...on line 50

  • allanallan Posts: 62,992Questions: 1Answers: 10,367 Site admin

    Can you paste in your entire PHP file please?

    Allan

This discussion has been closed.