During developing my custom local plugin i need to save specific users from an edit form.
I successfully saved the list of the user, in edit_form.php:
$options = array(
'ajax' => 'core_user/form_user_selector',
'multiple' => true
);
$mform->addElement('autocomplete', 'userids['.$section->id.']', get_string('secretery', 'local_sec'), array(), $options);
and in edit.php:
foreach($fromform->userids as $key=>$users){
foreach($users as $user){
$new_secreterly = new stdClass();
$new_secreterly->season_section_id = $key;
$new_secreterly->user_id = intval($user);
$DB->insert_record('local_sec_secreteries', $new_secreterly);
}
}
I would like to load these records if already exist in the db.
I may use tags form element insted of autocomplete not sure.
Just found this function :get_item_tags_array($component, $itemtype, $itemid, $standardonly = self::BOTH_STANDARD_AND_NOT,
$tiuserid = 0, $ashtml = true)
But not sure how to pass the fetched datas from db?