generate and store UUID

Presumably you have that as an eval'ed default on an element? What element type? What are the ACLs?

I tried logging in to your server to look, but the credentials in your My Sites don't work.

-- hugh
 
It's storing fine in my DB.
An element default is only applied to new records.
So if you have added this element to an existinging table with already existing records you must add this UUID directly in your DB via e.g. phpMyAdmin.
Same if you are adding a calc element. It will only store in DB if the record is (re)saved.
 
I see! Yes it is applied correctly on new records and on existing ones when saved again.
Ok so I have to figure out a way to update existing records via phpmyadmin.
thanks
 
Hmm, are you creating a UUID via calc element? So changing it with every save?
Is this really what you want to do?
 
You said "I see! Yes it is applied correctly on new records and on existing ones when saved again." This sounds like calc element.

To create a unique ID which doesn't change put the code in the field's default (set to eval).
I assume this is what you have done but in this case it won't add a value if saving an existing record.
 
yes that is what I did: put code in new field?s default, set to eval=yes

Now, when I open an existing record, UUID is already generated and filled in. When I save, record is stored.
Why you think it won?t add a value if saving existing value?
I need to be sure UUID value never changes for a record.
 
yes that is what I did: put code in new field?s default, set to eval=yes

Now, when I open an existing record, UUID is already generated and filled in. When I save, record is stored.
Why you think it won?t add a value if saving existing value?
I need to be sure UUID value never changes for a record.

Defaults are only applied to new records. Once a record exists and you edit it, no defaults are applied, we just use the existing value from the database.

-- hugh
 
Ok, maybe there's a misunderstanding.
If you are opening a new record the UUID is created and stored.
If you are editing one of these records created AFTER you've added the default you'll see the UUID.

But if you are editing a record created BEFORE the default was added the UUID field will be empty and the Fabrik form won't store a UUID for this "old" record.
Is this what you are seeing? This would be correct.
The UUID for the "old" records must be created manually.
I need to be sure UUID value never changes for a record.
Set element's add and edit access to something like "nobody"
 
ok records created before UUID field was added have value NULL in db (as expected).

Now when I open a record for editing that was created before UUID field was added, it is not empty!
There is a UUID value inserted into that field...when I save, it is stored.

Would be great for me...but I am a bit confused now because you say this is not possible? What am I missing?

Set element's add and edit access to something like "nobody"
Thanks for the tip, I just set value "read only" in advanced element settings to "yes", so nobody can manually change the value in UUID field.

code in default field:
Code:
$db = JFactory::getDbo();
$db->setQuery('SELECT UUID( )');
$u = $db->loadResult();
return $u;
 
Yes, it's enough to have it there (but it was the wrong one (7....) first).

Ok, replicatable:
If an element content is NULL the default is added also in existing records.
Edit: if the user has edit access (doesn't matter if element is set to "Readonly")
Not sure if this is intenionally.

Anyway you should set your element access to make the element "really" readonly.
 
Last edited:
ok thanks for confirmation!

element access Form (edit): here only user level can be set (oublic, guest,...super user)
don?t have an option here to set form edit of element to "no" or something similar
 
Interesting. I need to look at that behavior. The theory is that we don't apply defaults at all for existing forms, although I recently tweaked thing to try and make it so we apply defaults to new instances of repeat groups, as they are effectively 'new rows", even thought they belong to an existing form.

However, I can see that it would be useful behavior to have optionally defaults applied on existing rows if (and only if) the value is NULL in the table, which would handle the case of adding a new element to a form with existing data.

Obviously I need to dig deeper in to the code to see what's happening.

Apologies for the confusion. Once again, Fabrik surprises me. :)

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

Thank you.

Members online

No members online now.
Back
Top