Page 1 of 1

CreateInputDropdown: Value difference from Selection

Posted: Mon Dec 26, 2011 10:33 pm
by musicscore
I try to make a dropdown, but the text in the selection should be different from the value.

Code: Select all

<select name="1enddate_Month">
<option label="January" value="01">January</option>
<option label="February" value="02">February</option>
<option label="March" value="03">March</option>
<option label="April" value="04">April</option>
<option label="May" value="05">May</option>
<option label="June" value="06">June</option>

<option label="July" value="07">July</option>
<option label="August" value="08">August</option>
<option label="September" value="09">September</option>
<option label="October" value="10">October</option>
<option label="November" value="11">November</option>
<option label="December" value="12" selected="selected">December</option>
</select>
I looked in the Api documentation but could not find the solution.
Can someone help please.

I tryed :

Code: Select all

$this->smarty->assign('input_month', $this->CreateInputDropdown($id, 'item_month', $month_list, '-1', '$month_number'));
The value is always the name of the month ($month_list = array) but should be the number.

Please help.

Re: CreateInputDropdown: Value difference from Selection

Posted: Tue Dec 27, 2011 12:36 am
by calguy1000
The CreateInputDropdown function has always been 'backwards'.

i.e:

Code: Select all

$data = array('January'=>'01','February'=>'02' ...);
$smarty->assign('monthdropdown',
   $this->CreateInputDropdown($id,'month',$data,-1,$the_month);

Re: CreateInputDropdown: Value difference from Selection

Posted: Wed Dec 28, 2011 10:51 am
by musicscore
Calguy,

Thanks. With your help I did it.
I'm writing my first module and sometimes I need some help.
CMS Made Simple community is very helpfull. That's the most powerfull thing about CMSMS. Many people can write php scripts but only the best are willing to help others.