SOLVED: Need to tell if I got to a form via "view" or "edit" - look at the URL? in php?

bggann

Active Member
I have a form that includes a field "complete" which a user sets when they submit the form to indicate the data is "official". Periodically, the submitter may need to update the form, so when they open a "completed" form, they are warned and the "complete" field (in the form, not the database) is set to 'incomplete'.
I do this with php plugin on the form that catches you are loading a form that is marked "complete".

The problem is that there are "consumers" of the form who need to open it to look at it, print it, or download it. The same "on load" php that I use to "warn" a user they are opening a completed form, also triggers when a viewer opens the form in "detail" or read only mode. So they get the same warning, and the field in the form is marked "incomplete".

I need a way to tell, in the php, that the form is being opened in "detail" not "form" view. Then I can abort the 'warning you are opening a complete form" and the reset of the form to "incomplete".
This is in the URL calling the form, so if I can get to the parameter in the URL, I can trap that in the php - just see that the mode is detail.

Is there a way to access URL parameters in the form's php plugin? I saw discussions on how to "set" a field from a URL, but not how to see standard URL parameters such as the view mode.

-Bob
 
You can access query string args (in this case you'd want 'view') thusly, using the J! framework ...

Code:
$app = JFactory::getApplication();
if ($app->input->get('view', '') === 'form') {
   // do your thing
}

... or The Fabrik Way, which also takes into account Fabrik ACL's ...

Code:
if ($formModel->isEditable()) {
   // do your thing
}

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top