Conditionally hide column in List and/or Element in Form

Status
Not open for further replies.

bontemuis

Member
I have a Profile form with some personal data. Suppose I want users to give an option to hide with a checkbox in the Form, e.g. their email address (column) in a List, how would I do that? And the same question for a Details View?
In this post I read a comment "You can set "Filter colums"", but I couldn't find this option anywhere...
 
I recommend you to use additional calc element to either return the email element value or not depending on checkbox value. When using javascript to hide element, it might "flash" on load shortly, so in the worst case can even be readable for someone not meant to.
 
JS is never a security means. The user who knows how to can examine the page source or disable JS.

BTW: "Filter columns" is only about the filter layout.
 
Thanks both juuser and troester. I thought maybe this was standard functionality that I may have overlooked. However, I will try the calc element. And although I have many other talents :) I am not so much of a programmer (used to be with Cobol a few centuries ago). So suppose my elements would be named profile__email and profile__checkbox, what should be the php code then? Btw, tried the JS and indeed saw the "flash" ...
 
Something like this should do in the calc element:

Code:
if ('{mytable_checkboxelement_raw}' == 0) {
return '{mytable_myemailelement}';
}

or if you want to return something also when email is hidden

Code:
if ('{mytable_checkboxelement_raw}' == 0) {
return '{mytable_myemailelement}';
} else {
return "-";
}
 
Hi Juuser,

It took a while before I was ready for this, but your solution worked for me. Thanks!
Just one thing: the original email address was a field element with a guess link, so it was hyperlinked and opened directly my email program. Is there a way to do this with a calc element?
 
Something like this should work:

$myemail ='{mytable_myemailelement}';

if ('{mytable_checkboxelement_raw}' == 0) {
return "<a href='mailto:".$myemail."'>".$myemail."</a>";
}
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top