The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Apr 10, 2012 11:16 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Mar 20, 2006 4:51 pm
Posts: 28
Hello there,

I am developing a custom component for Joomla! 2.5 and its admin page contains a multi-select list. I've created this by adding the following to XML definition file.
Code:
<field name="destination" type="airportnamelist"
         multiple="true"
         size="10"
         class="inputbox"
         label="COM_FLIGHTS_FLIGHTS_FIELD_DESTINATION_LABEL"
         description="COM_FLIGHTS_FLIGHTS_FIELD_DESTINATION_DESC"
         required="true"
      />

and the option for the list is generated by the function below
Code:
public static function getAirportNameOptions()
   {
      // Initialize variables.
      $options = array();

      $db      = JFactory::getDbo();
      $query   = $db->getQuery(true);

      $query->select('code As value, name As text');
      $query->from('#__flights_airports');
      $query->where('published = 1');
      $query->order('ordering');

      // Get the options.
      $db->setQuery($query);

      $options = $db->loadObjectList();

      // Check for a database error.
      if ($db->getErrorNum()) {
         JError::raiseWarning(500, $db->getErrorMsg());
      }

      return $options;
   }

Now, while I can save the selected values to the database, I cannot work out how to make this multi-select list to highlight the saved values. Can anyone tell me how to do this? I looked through tutorials and forums but I didn't find anything related to this :(

_________________
~~ My website - Can You Chopstick? ~~
http://www.canyouchopstick.com/


Top
 Profile  
 
PostPosted: Tue May 01, 2012 7:23 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue May 01, 2012 7:21 pm
Posts: 1
You need to use implode on saving it as comma separated array and explode on displaying.

Following is a detailed guide on doing that.

http://joomla-answers.[URL banned].com/2012 ... -view.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 



Who is online

Users browsing this forum: orlov and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group