Hide calc element in form view only?

chrisyork

Member
I have a calc element which is a hyperlink formed using a value of the record (to link to a 'subform' with related data, in this case images). My calc element is on a form with a repeating group - you might be able to see why I need a subform, given the problem with Ajax upload and repeating groups...

I want to be able to see it in list and detail view, but hide it in form view and I hope the reason is obvious...

In form view (data entry) when you add a new group within the record the new calc element has the wrong hyperlink (it takes its value as the first 'row' in the joined group). It is also confusing for someone entering data because that link would take them to another form before they have completed all the 'repeat groups' in the first stage of data entry. The subform is the repeat group data (as a single form) which includes an ajax upload element - this has 'solved' the big problem I have been having with the repeat groups, even though its a bit clunky, so just the final hurdle to make it usable.

Things I have tried:

Element hidden - fine for list view, but hidden in detail view and form view.
Javascript hide on load - if the id is null, hide calc - doesn't work
Access levels - the hyperlink is still clickable no matter what access level is set to (so you can see but can't change the element)
Calc on save - means that in list and details view the element is also empty
Ajax calc - watch for change of id (but this doesn't change until the record is saved?)

Any help on this would be appreciated.
Kind regards
 
Trying to think about this another way and utilise the Fabriking tutorial... Is there a way of detecting that the form is in edit / add mode rather than details? So if its in add/edit the element is not displayed, but in details mode it shows a calculated field as a link to a specific row of another list (I know how to do the last bit!).

I'm thinking along the lines:
Code:
If ($FormMode = "add/edit")
  {
  return 'Hidden';
  }
else
  {
  return $link
  }

So what I would need to do is find out how to make that first line work! Is there something that I can insert into a form when its loaded that determines the state of the Form

Thanks in advance...
 
You could make a custom add/edit link on your list where you add an extra parameter. e.g. ?editable=1
Then in you calc element you can query this with:
Code:
if (isset($_GET['editable'])) {
return 'Hidden';
} else {
return $link;
}
 
Thanks Paul - apologies for not responding sooner, the notification of your reply didn't get to me.

Cunning idea.Works nicely.

So... I can change the text output to say 'Hidden', which is useful instead of a link that won't work (as it is based on a value that hasn't been saved in Add mode!).

Being able to actually hide the element would be next step...

You could make a custom add/edit link on your list where you add an extra parameter. e.g. ?editable=1
Then in you calc element you can query this with:
Code:
if (isset($_GET['editable'])) {
return 'Hidden';
} else {
return $link;
}
 
Why don't you just use CSS? I do this all the time....

Code:
#form_(idnumber) .fb_el_tablename___elementname {display:none}
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top