Add a record but not edit it once it's been added.

Status
Not open for further replies.

stevenpryer

Steven Pryer
I'm developing an eVoting system.

I've created a list of candidates. I've also created a list of votes, with a databasejoin for the candidates, and a databasejoin for the voter (voter_id). I've created a copy of the vote list (called MyVote) , and filtered it so that voter_id equals {$my->id}.

I've added a Fabrik Form menu item for the MyVote list, and for Fabrik Form options, I've set Row id -1 and keyname voter_id.

I'd really like users to be able to add a new vote, but not edit it once it's been added. To this end I've made the following configurations:
  • MyVote List: Access: Add Records = Registered, Edit Records = Super Users
Registered users can add a new vote, but unfortunately (in spite of the setting above) can also edit that vote. How can I stop registered users from being able to edit the vote once it is created?
 
No, if edit=superadmin a registered user can't edit.
did you set it in the correct list?
maybe you have to log out and clear cache.

gesendet mit Tapatalk
 
Hi Troester, thanks for your reply :)

I don't want the registered user to be able to edit, but I do want them to be able to add a new record. Apologies but I'd forgot to mention that the databasejoin element in the votes list (called vote and joined to the candidates list) had the following configuration:
  • Access: Form (add) = Registered, Form (edit) = Registered.
Which I realise would overide the List Access setting. But when I change this to the following:
  • Access: Form (add) = Registered, Form (edit) = Super Users.
Users can't add a new record?

In summary I'd like users to be able to add a new record, but not edit it once it's added.
Thanks in advance for any help :)

This is all on a test site, so I'm happy to provide a Super user account, if it helps?
 
Last edited:
As Toester said, if you've got Edit Rows set to Super Admin on the list, then registered users shouldn't be able to edit. Are you sure you set that on the right copy of the list?

-- hugh
 
Just to confirm, I am using the correct list, it's just that I'd edited the Access properties for the Element, to allow Registered users to edit.
Thanks, Steven
 
I'd really like to resolve this if possible. I'd like registered users to be able to add a new record, but not edit it once it's been created. I realise that I might be thinking about this in the wrong way, and perhaps I need to limit the number of times a record can be edited to one for example? But I'm hoping for some advice as to the best way to achieve this.
Many thanks in advance, Steven
 
My approach so far, can be captured by the following steps:
  1. Create a new empty list with default settings.
  2. Create the following elements with default settings:
    1. 'User' element called user_id
    2. 'Field' element called create_but_no_edits
  3. Adjust Access property for the create_but_no_edits element, so that Form (edit) = Super users.
  4. Create a new Menu item for this newly created Fabrik form (Access = Registered).
  5. Fabrik Form options: Row id = -1, Key name = user_id
I then login, in the hope that I could create a new record, and then view it afterwards, without being able to make subsequent edits.
Interestingly the user_id can be edited (I realise that normally I would hide this element).
But the create_but_no_edits element has a visible label, but no input box.

To be clear, I'm hoping to be able to make an input here, because I have the Add access, but not be able to edit, because I'm not logged on as a Super user.
 
Last edited:
I've even tried to use this forum's posted method for limiting the number of edits, but am getting the following error when I add the onBeforeStore php plugin.
  • Fatal error: Call to undefined method FabrikFEModelForm::getElementValue() in /home/test/plugins/fabrik_form/php/php.php(453) : eval()'d code on line 1
I've checked and I am using the correct element name, based on the suggested php code below:

$edit_count = $formModel->getElementValue('yourtable___edit_count');
$formModel->updateFormData('yourtable___edit_count', ++$edit_count, true);
 
I think I can replicate:

It's only related to the Fabrik form menu item, it's working fine if displaying the list.

The menu item doesn't respect the list add/edit access settings. I don't know if this is a bug or a "feature".

I think the form menu with row=-1 was thought to give a user the possibility to add and edit one single "own" record. If he has multiple records the menu will always show only the first one, so this approach via form menu is no general one.
 
Hi Troester, thanks for your thoughts :)

I can see what you mean about it working if I were to use a list, but this doesn't quite fit my needs unfortunately :-/

Maybe Hugh will have an idea around limiting the number of times a record can be edited?
 
OK, looks like that was a corner case we hadn't anticipated, with the rowid=-1 thing, and allowing add but no edit (not something anyone has done before).

I'm testing a fix, will commit soon.

-- hugh
 
Many thanks, just got back from a week away skiing :) All is working now. Here are the actions that I performed:
  1. Fabrik had an update available 3.4.3 which I think is recent and I hadn't seen before, so I updated to that.
  2. I then updated using GitHub (this seemed to add 14MB to my site, presumably that's right?).
  3. It didn't seem to work properly initially, so I upgraded Joomla from J3.4.8 to J3.5.1.
  4. It then worked, but the email form plugin stopped working.
  5. I then downloaded the email form plugin 3.4.3 from Fabrikar download site, and installed it.
All seems well now, many thanks for all your help :)
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top