hidden field element not storing {$my->groups} consitently

SoilentRed

Caaan do!
It's very odd to me. I have a form with a hidden field element listening for {$my->groups}. It seems like about 3/4 of the time, the form captures the user's groups. Other times, it captures nothing. This is only verified by going into phpmyadmin and checking what's there. I have to update the empty fields myself which is a pain in the fanny. can someone help shed some light on why this is happening. Why some of the user's groups are being captured, but not others? Your help is always appreciated.
 
Maybe a string if the user belongs to only one group and an array (breaking) otherways?
 
Not sure if I'm following you. They all belong to the default 'Registered" group and are assigned to at least one other upon their signup. So, in phpmyadmin, a typical entry from a user in the membergroups coulmn will look like 2,15 or 2,16 or what have you...
 
@troester - it won't matter if there is more than one group, as the replaceWithUserData() helper func takes care of that, see around line 810 in ./components/com_fabrik/helpers.parent.php. It'll render any user object properties which are arrays as imploded comma seperated strings.

So my question is the same as yours ... what is the exact setup? I presume it's an eval'ed default? And that it is only expected to save the groups on "new", not "edit"?

-- hugh
 
Set up as follows::

Hidden: yes
default: {$my->groups}
Eval: no
Input type: Text
Max length: 255
Disable element: no
Read only: no
Auto complete: Browser
Speech recognition: no
Bootstrap Class: input-medium
Format: Text
Integer length: 11
Decimal length: 2
Number Format: no
Thousand Separator: BLANK
Decimal Point: BLANK
Format string: BLANK
Input Mask: BLANK
Display as QR Code: No
Guess Link Type: NO
Link target: Default
Link rel: None
Link title: None
 
The "Default" is only applied if adding a new record, so it stores the groups belonging to one who creates the record and won't reflect
Do you have access settings on this element?
 
These were all new records that that it was happening to. I'm viewing it on phpmyadmin. So, if {$my->groups} wasn't recorded on submission, I update it on phpmyadmin. And yes, I have access to the element settings on fabrik.

It's weird. It doesn't look like the problem happened at all this week. But, I haven't changed anything.
 
What Beate was asking is if you have set any access permissions on the element, or if it's just Public. And if it's public, have you made any changes to the J! default setup for guest user.

Sent from my HTC One using Tapatalk
 
And is the form only accessible for Registered? If not, and you have guests submitting the form then I don't think that element will save anything.

-- hugh
 
In which case, I really can't see any reason it wouldn't work.

If it starts happening again, I'd suggest replacing the placeholder with some actual PHP code to return the group memberships, just to rule out our placeholder replacement code as being the culprit. Something like ...

Code:
return json_encode(JAccess::getGroupsByUser(JFactory::getUser->get('id')));

... although JSON may not be your preferred format, in which case you'd implode() the group array.

Code:
$mygroups = JAccess::getGroupsByUser(JFactory::getUser->get('id'));
return implode(',', $myGroups);

-- hugh
 
Yeah, it's still happening. So, would I put the suggested code in in the default field? Thanks for your help and your patience. I just want to get it right.
code-here.jpg
 
No.
What happens if you set the element to hidden=no?
What are your element access settings (not the list edit/add access or menu settings)?
 
Sure. FYI, I'ved since changed it back to {$my->groups}.

With Hidden=no, it seems to have worked fine. when it's toggled to yes, it works for the vast majority of the time as well.

In any case, I toggled it to "no" and when I went to the form my groups were pre-filled, and when I hit submit, the data was captured just fine on phpmyadmin, so it worked.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top