You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2011-10-25 10:58:44

Reini
Member
Registered: 2009-10-21
Posts: 35

Usage of User::dropdown

Hello everybody,

I am using the User::dropdown command in order to display a user dropdown (surprise, surprise...).
Now, when I select an user from that dropdown I want to fill another input field depending on the selected user. I think I can do that with the parameter "toupdate" of the User::dropdown method. But the question is, how do I have to do that correctly?
Which fields of the "toupdate" array do I actually need? I tried it with the following parameters so far:
'value_fieldname' => [value of the 'name' attribute of the dropdown]
'to_update' => [the id of the input field which should be updated]
'url' => [the URL which should be called in order to retrieve a value for the to-be-filled input field]
Is this usage okay or what is wrong/missing?

Best regards,
Reini

Offline

#2 2011-10-27 15:42:04

Reini
Member
Registered: 2009-10-21
Posts: 35

Re: Usage of User::dropdown

Hmmm, unfortunately no reply so far... :-(
Anyway, it seems that I figured it out by myself. Just for those who are interested anyway, I was able to bring it into function by myself, using this piece of code:

$paramscomment = array('value' => '__VALUE__');
$options = array('name' => 'nameOfDropDownField',
                 'entity' => 0,
                 'right' => 'all', 
                 'toupdate' => array('value_fieldname' => 'value',
                                                    'to_update' => 'nameOfToBeUpdatedInputField',
                            'url' => 'path/to/my/ajax/file.php',
                                                    'moreparams' => $paramscomment)
                );
User::dropdown($options);

BUUUUUT: this actually updates the innerHTML of my to-be-updated field. What I would like to have is also the value attribute be updated in order to use this value later on when I submit my form. Any idea how to realise that?

What I tried as well is to attach a change event manually to my User dropdown by using the "on" method of ExtJS, but the event handler I attach to it, is never called. Is it possible that my manually attached handler is being deleted by the above mentioned User::dropdown method of GLPI?

Offline

Board footer

Powered by FluxBB