Conception advice

Incremental

Member
I'm designing a contact form and I'm not quite sure of the Fabrik way....
I've made a Contacts List (stored in one DB table) containing both user and admin informations.
I've made in the frontend, menus to access to the form (public) and perform administration on the list (superuser).

As I have for exemple two textarea elements : 'contact message' and 'Reply', these 2 fields are visible in the public form (only the 1st should be visible, the second is only to be filled by the admin).

1) Is it possible to dynamically hide an element [textarea has no hidden property] ?
2) Do I have to clone the List / Form / Elements / Groups, to have another "kind of view" mapped on the same database table ?
Just to have one Form with only public infos, and one List/Form with full admin infos ?

If it's the case, it's sounds wasting to generate so much elements as we could programatically decide (at loading) if fields are to shown or not ?

Thanks a lot for your helping advices.
Regards
 
You can set access levels for every element, so set form view to "superadmin", details view to "registered" (assuming the user should be able to see the reply;))

List access settings and prefilters depend on what you want to show (if a user should see his own records only set a prefilter).
 
Wow great and simple !
I changed the Reply element with Form View = Superuser.
The textarea field disapears when not logged in ... BUT his label remains :(
Could it be possible to hide it also ?
Regards
 
troester,
I have new remarks, as I find your solution great ;)
For my application, the user has no access to his records. Just the initial contact form.

With the ACL, if the Fabrik Admin goes to the front end contact form, he sees all technical hidden fields that he shouldn't see. (contact status, empty admin reply to a contact not yet sent).
In this case, for the Admin, the form should behave like for Public.

BUT, in the administration part :
if the Admin 'View' or 'Edit' (in a form) a contact from the list, he should :
  • not see the 'Answer' text field, if the contact has the status 'New'.
  • see the 'Answer' text field, if the contact has the status 'Replied'.
Then I would like also to perform PHP to change the status on VIEW from 'New' to 'Read'.

Is it possible ?

Thanks for your advices.
 
I changed the Reply element with Form View = Superuser.
The textarea field disapears when not logged in ... BUT his label remains
You would also want to set the details acl to something higher than the logged in user.

With the ACL, if the Fabrik Admin goes to the front end contact form, he sees all technical hidden fields that he shouldn't see. (contact status, empty admin reply to a contact not yet sent).
In this case, for the Admin, the form should behave like for Public.

BUT, in the administration part :
if the Admin 'View' or 'Edit' (in a form) a contact from the list, he should :
  • not see the 'Answer' text field, if the contact has the status 'New'.
  • see the 'Answer' text field, if the contact has the status 'Replied'.
Here you would need to copy the list so that the original is shown in the admin and the copy is used in the front end.
Create a Joomla 'nobody' view access level - e.g. one that no user groups have access to, and assign that to the copied list's fields.

Then I would like also to perform PHP to change the status on VIEW from 'New' to 'Read'.
You can use the PHP form plugin for this one, there are examples in the wiki page on how to update an element's value :
http://fabrikar.com/forums/index.php?wiki/php-form-plugin/

-Rob
 
Thank you rob for your advices :)
OK for ACL this logic should make a great topic in Wiki.

Before trying it, I understand now that with PHP form plugin, I could perform code 'On load' and then change my status, even if there is no 'Save' of the form, as I would use 'View' and close the popup. Right ???

I was also wondering if it could be done through a specific template, with PHP rendering or not elements, depending on context ???
List duplication has the inconvenient to duplicate all (list, groups, forms, elements) and complexify interface !
Thus developpers really need to document more precisely their development !
 
I understand now that with PHP form plugin, I could perform code 'On load' and then change my status, even if there is no 'Save' of the form,
using the $formModel->updateFormData changes the value of a field in a form, so it would still need to be saved for the change to take effect.
If you wanted to automatically alter a value in the database itself before load you would need to write a db query to do that.
That would work although depending on why you want that change its rather obscure to do it on a form load. Perhaps a list update col plugin would make more sense?

I was also wondering if it could be done through a specific template, with PHP rendering or not elements, depending on context ???
Think about it - the code runs, the database is queried to get a record, its then manipulated in various ways and the very last thing that happens is that the data is rendered to the template.
So if you wanted to edit and save a value to the database and use it in the form then putting code in the template is too late in the process.

Do I have to clone the List / Form / Elements / Groups, to have another "kind of view" mapped on the same database table ?
No need to clone the list, you can create new menu items and supply a different list template, and/or select which elements are shown in the list.
 
Thank you Rob for your answer, but the topic is quite long and confusing now.
There are 2 requirements for my Contact application :
1) change the Contact status from 'New' to 'Read' when I open the detailed form. I would like to automatically alter it during onLoad() ==> The contact should not anymore considered as a 'New' one.
Have to try the query call.

2) Depending on who and when the data is accessed in lists and forms, I would like a different RENDER, with hidden or not fields (label + data).
I understand that using templates could be more powerfull (but complex) than using ACL (for simple cases).
Of course, it's not in template that data could be manipulated.
Am I right ?
 
when I open the detailed form.
Do you mean the details view , or the form? You can't have both at the same time. The detail view is read only and the form view is editable. But in either case the query should work. I think I updated the php form plugin wiki page with a similar example today.

2) I'd see how far you could get with the element acl before trying to swap templates per acl level. I've never had a situation where I've had to do that - the acl is flexible enough to deal with most things, and templating based on user acl levels can make things brittle/less secure if not coded well
 
Thanks Rob for your answer.
I was thinking (because in admin part) to a form, but there's no difference for me.
The status is here to tell (in the list) the contact message was read, some day.
While the list is displaying the beginning of the message, the View or Form displays the full message).
Thanks a lot for your quality contribution to the wiki, it's really more clear for me ! :D

2) I wondered that, because of my 3rd topic in this post.
The textarea field disapears when not logged in ... BUT his label remains
I love ACL concept, but there was the label bug...
N.B : in another post I also mentionned the case where :
  • when not admin the fields should be hidden (OK)
  • when logged as admin I had the access to admin menus in frontend and the fields are visible (OK)
  • BUT when logged as admin and looking the public form in frontend, all the hidden fields are visible (KO)
==> is it possible to mix ACL (for users) and position in the site ?
Don't know if I'm clear, but the Admin should see the regular Contact Form (like public, with "hidden fields" invisible), and access to the admin part with "hidden fields" visible (of course without to log in and out !)
 
If the admin is logged in he can't see the identical form with one template in different ways.

I think in this case you'll have to copy the list/form and set element ACL to public and nobody or create a custom "public" template (I think there's no security risk if the "public" template is displaying only elements which are public anyway).
 
Hi all,
1) I tried to make a specific template, but don't know how to test ACL level before to display Group elements in default_group.php. Any idea ?

2) I modified Form template, but where is the View one ?
/details/tmpl/ contains only a default.xml

3) as my public form is called in a Joomla article, containing
{fabrik view=form id=1 contacts___ContactsFormID=1 show-title=0}
where should set a specific template AND where to code it ?

Thanks
 
Thank you Troester for your answers.
1) My wish was not displaying an administrator field for Administrator, when watching a Public Contact form.
I tried to make a specific template hiding a field, based on its element name.
You mean that it's not possible to test logged user's rights in a template ?

2) OK thanks, I'll watch...

3) Great ! I missed it in that page. I modified the Wiki to be more explicit !
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top