Hey all,
So I really appreciate this plugin, but I want to know how I can pre-populate fields? I haven't really looked at the code yet, I was thinking someone can save me some time;)
If not, I'll post my results here.
Thanks in advance,
Mahmoud Abdelkader
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- mahmoudimus@mabdelkader
mahmoudimus - 0 likes
- mahmoudimus@mabdelkader
mahmoudimus - 0 likes
- mahmoudimus@mabdelkader
mahmoudimus - 0 likes
- mahmoudimus@mabdelkader
mahmoudimus - 0 likes
You must log in to post replies.You get the form entity using the form_get_maps(form_id).
For each entry in the maps, get the field id for this entry
This field has an internal_name, which if matches, should be set with the form
I'll see if I can use flexprofile_set_data() function instead. Will report back results.
form_set_data($entity, $data)
This function takes an array data, with the internal_data strings as array access keys, which has instantiated stdClass() objects per field definition (internal_data strings). The attribute "value" stores the value respective to it's internal data string.
$entity is the ElggEntity that allows metadata, for flexprofile, it's the ElggUser.
Looks like form_set_data() and flexprofile_set_data() are exactly the same function.
Looks like the metadata is being set using create_metadata(), so you can technically get the $user object and just use the regular metadata methods to set and retrieve values.
For example, if a form field internal_id is "flex_plugin" then $user->flex_plugin = "somevalue"; or echo $user->flex_plugin; would work
Yep, just confirmed it
$user->setMetaData(%internal_name%, %value%);
$user->getMetaData(%internal_name%);
works fine.
I think it would be wise, however, to use form_set_data() to control the access. You can always use access_id to override it.
Hope this helps someone:)