solved Form Select

nate
@nate
11 years ago
917 posts
I have a select element in a form that is suppose to run a query for it's options. Instead of running the query each time it seems to only query them the first time and from then on it keeps loading the saved options from the db.

$_sel = xtStem_get_stem_songs($_user['user_active_profile_id']);
// Select a type
$_tmp = array(
   'name'       => 'audio_stem_song',
   'label'      => 'song',//999
   'help'       => 'Select a song',
   'type'       => 'select',
   'options'    => $_sel,
   'validate'   => 'not_empty',
   'required'   => true
);
jrCore_form_field_create($_tmp);

Is there a work around?
updated by @nate: 02/26/14 07:29:23PM
brian
@brian
11 years ago
10,149 posts
That's cause you've got that wrong - it needs to be:

$_tmp = array(
   'name'       => 'audio_stem_song',
   'label'      => 'song',//999
   'help'       => 'Select a song',
   'type'       => 'select',
   'options'    => 'xtStem_get_stem_songs',
   'validate'   => 'not_empty',
   'required'   => true
);
jrCore_form_field_create($_tmp);

Note how the "options" is set to the name of the function you want to run. NO PARAMS can be passed in however, so you'll need to adjust your xtStem_get_stem_songs() function to NOT take an argument, and inside just do:

global $_user

and then grab the user var that way.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 01/26/14 07:25:54PM
nate
@nate
11 years ago
917 posts
I'm not the author but I would have easily made the same mistake.

Thanks.
SteveX
SteveX
@ultrajam
11 years ago
2,584 posts
I guess I was the author, but not necessarily a mistake, we just have to parse whatever xml is made available by the app-in-development.

Quote: //Get list of stems //got it //move on



--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
nate
@nate
11 years ago
917 posts
I thought it was likely an updated way to do it.
SteveX
SteveX
@ultrajam
11 years ago
2,584 posts
Not sure, I haven't checked.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

Tags