solved multiple select live search

Melih
Melih
@melih
10 years ago
198 posts
Hello,

I need your help because i have no idea how to do this :)

I created a module using Aparna to be able to use in Genosis. I need a mutiple select live search form field like "Existing Event Sources" in jrGenEvent create page. The form field i need will search the profile names and write the profile ids to the database.

I tried to make this by examining the existing modules but i couldn't do anyting because i don't know much about php or coding, unfortunately.

I would appreciate it if you could help me.
updated by @melih: 11/26/14 04:08:33PM
brian
@brian
10 years ago
10,148 posts
That is going to be a bit tricky to setup, as that's a completely custom field used by the Genosis Events module, so you'll want to check out the modules/jrGenEvent/index.php file, and look for the "view_jrGenEvent_update()" function - that contains the calls to "selectize" (which is the javascript package that provides the enhanced select).

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
Melih
Melih
@melih
10 years ago
198 posts
Ok Brian, I will look over again. Thank you ;)
Melih
Melih
@melih
10 years ago
198 posts
This is way too over me, i tried it at least ten time starting over and over again and i still can't do it. I gave up. :(

Is there an easy way to draw profile names and profile ids in multiple select by using form designer or index.php?
updated by @melih: 10/25/14 02:24:31PM
paul
@paul
10 years ago
4,326 posts
You could do it in a 'multi_select' form field, but there is no 'multi_live_search', which is what you originally asked for.
For a 'multi_select', do something like -

    $_tmp = array(
        'name'    => 'field_name',
        'type'    => 'select_multiple',
        'label'   => 'Select Profiles',
        'help'    => 'Your help string for this field',
        'options' => 'yrModule_get_profiles',
        'default' => 0
    );
    jrProfile_register_quota_setting('yrModule', $_tmp);

'yrModule_get_profiles' would be a function to return key/value array pairs of _profile_id and profile_name
hth
Pa


--
Paul Asher - JR Developer and System Import Specialist
Melih
Melih
@melih
10 years ago
198 posts
Thank you Paul,

Unfortunately, my actual problem is writing the function.
paul
@paul
10 years ago
4,326 posts
function yrModule_get_profiles(){
    $_s = array(
        "order_by"    => array("profile_name" => "ASC"),
        "limit"       => 1000000,
        "return_keys" => array("_profile_id", "profile_name")
    );
    $_rt = jrCore_db_search_items('jrProfile', $_s);
    if (is_array($_rt['_items'])) {
        $_out = array();
        foreach ($_rt['_items'] as $rt) {
            $_out[$rt['_profile_id']] = $rt['profile_name'];
        }
        return $_out;
    }
    else {
        return false;
    }
}



--
Paul Asher - JR Developer and System Import Specialist
Melih
Melih
@melih
10 years ago
198 posts
Thank you Paul,

This brings profile names but it does not write the ids to the database. It just writes the word "array" to the db.
updated by @melih: 10/26/14 12:41:17PM
paul
@paul
10 years ago
4,326 posts
You need to process the selected profiles in the form view's 'save' function into the format that you want them saving on the datastore. Are you doing that?


--
Paul Asher - JR Developer and System Import Specialist
Melih
Melih
@melih
10 years ago
198 posts
No, i didn't do that. Actually i don't know how to do that.
Melih
Melih
@melih
10 years ago
198 posts
I added an image field and it worked so i didn't think adding another thing to somewhere else :s
Melih
Melih
@melih
10 years ago
198 posts
there was something else wrong. I did it (but don't ask me how :))
Thank you Paul, so much.

Tags