DropDown with default?!?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

DropDown with default?!?

Post by jmansa »

I'm wandering how to make a dropdown list from db with one specific record as default.

Im getting the data like this:

Code: Select all

$pricelist = array();
    $q = "SELECT * FROM ".cms_db_prefix()."module_sms_prices WHERE product = $product_id ORDER BY price ASC";
    $dbresult = $db->Execute( $q );
    if( $dbresult ) {
    while( $row = $dbresult->FetchRow() )
      {
	$pricelist['kr. '.$row['price'].',-'] = $row['id'];
      }
    }
	
	$this->smarty->assign('pricelist_input', $this->CreateInputDropDown( $id, 'price', $pricelist, -1));
This part works fine but in my db I have a field called "active" and one is set to "1". How do I make that certain record selected as default???

Hope somebody can understand this and thanks in advance...
Peciura

Re: DropDown with default?!?

Post by Peciura »

How do I make that certain record selected as default???
http://www.cmsmadesimple.org/apidoc/

To be more precise
http://www.cmsmadesimple.org/apidoc/CMS ... utDropdown
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

Re: DropDown with default?!?

Post by jmansa »

Not sure how and which parameter sets the selected...
Peciura

Re: DropDown with default?!?

Post by Peciura »

It is a copy from Products module "function.admin_prefstab.php" file.
Variable $sortorder contains value that should be selected from available options.
$sortorders = array(
   $this->Lang('ascending')=>'asc',
   $this->Lang('descending')=>'desc
');
$smarty->assign('input_summarysortorder',
  $this->CreateInputDropdown($id,'sortorder',$sortorders,-1,$sortorder));
Post Reply

Return to “Developers Discussion”