Hello together,
I want to show, render readonly or hide Form Fields according to the rights of the logged in user.
For security reason I want to evaluate all that on the server - not Javascript.
Are there any additional Informat in the data Array possible like
$form->data["exampleField"]["show"] = false;
would be a cool approach.
Or are there any Ideas how to influence the rendering of fields in Custom Code?
have a great day
Frank
Hi Frank,
The simplest way to handle show/hide is probably using conditional CSS - you can add classes to the input elements; then in the Load CSS box use PHP to check the users groups and load the appropriate class CSS.
Changing readonly is more difficult. You could do it with Custom Code actions to load either this version or that version. My inclination would be to set the input to readonly by default and then use JavaScript to make it writable when appropriate.
Alternatively - depending on what you need to manage this way - you could add both versions in separate containers and then use PHP in the container to show or hide all of it's contents.
Bob
Hi GreyHead,
I think I got the Idea,
Now there is one more approach that I am thinking about.
I want to store the Accessinformation for every field as metadata.
Would it be a goog Idea to use Cronoconnecitvity to get all Fields of a specific Table dynamically and then store the Permissions for each Field in a seperate Tabele which has a records for all Fields?
thank your for your help
and best regards
Frank
Hi Frank,
I'm not clear what you are trying to do here? CC is fine for displaying listings - and you can edit data from there too if that is useful.
If you want to store data about form inputs, then it might be simpler to add them as meta-data to the input element. You can use the Extra Params box in the form input to add entries like data-permission=aqx Does that help at all? Another way would be to save it in a separate file and include the file into the form code as needed.
Thank you again GrayHead,
is it possible to validate the entry in "Extra Params" against User Permissions on serverside.
Security is important in this project. I want to clear the data array for all fields that have no view permission.
Generally would be verry interesting: Is there Information about the field present in the data array?
Or is it even possible to set "Class" and "Extra Params" via data Array in Custom PHP Code?
I think this is my last question :-). Concept is getting clearer and clearer.
best regards
Frank
Hi Frank,
Sorry for the very slow reply.
There is no data about the input elements in the $form->data array - just the name and value. However, you could add whatever info you need into a PHP data array and include that into the form. You could perhaps use that to Unset() any unwanted values?
Bob