Write protection server side
Write protection server side
is it possible, from server side, to protect a whole table from writing, but allow only reading?
Editor::inst( $db, 'login', 'login_id' )
->fields(
Field::inst( 'login.login_id' ),
Field::inst( 'login.group_of_id' )
->options( Options::inst()
->table( 'group_of' )
->value( 'group_of_id' )
->label( 'name' ))
->set( false ), // only read
Field::inst( 'login.email' ))
->process( $_POST )
->write(0)
->debug(true)
->json();
I'm try "write(false)" and "set(0)", but both don't working.
Tank's
Replies
You can use one or more of the cancellable events:
https://editor.datatables.net/manual/php/events#Cancellable-events
or you can use ->set( false ) on every field
You can also use a Global Validator and notify the user that this is read only if changes have been made. Probably the most elegant solution I guess.
https://editor.datatables.net/manual/php/validation#Global-validators
for every field?
Gibt es nicht eine elegante Möglichkeit, dies für alle Felder zu tun?
Sorry.... in englis is better...
for every field?
Isn't there a way to make it elegant for all fields?
Yes, that is the global validator above which detects any change in any field. The same applies to the solution with cancellable events: you simply cancel any editing of existing or inserting of new records unconditionally.
Only if you want to use ->set( false ) you would need to use this on every field
Ja, das ist der obige globale Validator, der jede Änderung in einem beliebigen Feld erkennt. Dasselbe gilt für die Lösung mit löschbaren Ereignissen: Sie brechen einfach jede Bearbeitung bestehender oder das Einfügen neuer Datensätze bedingungslos ab.
Nur wenn Sie ->set( false ) verwenden wollen, müssen Sie dies für jedes Feld tun
(translation: deepl.com)
Tank's!
But, if I use a join one-t-may? Linke this: https://editor.datatables.net/examples/advanced/joinArray.html
How can protects this example?
It makes no difference whether or not you use a join.
I'm try, but cannôt protect to write. Datatables write in the data if I set(False) every fields....
My exaple don't work:
Could you use Markdown please to make your code legible (see link below).
And please post a test case as per the forum rules.
This is a simple example from my own coding - and it works:
This should also work:
As well as this:
Hi,
With the new (v2) versions of the PHP libraries for Editor, there is actually a
write()
method which can be used to disallow all write access - e.g.:Saves needing to put
->set(false)
on all the fields.Allan
tank's