Re: array on addElement, does not work => QuickForm
| From: | Louie Miranda | Date: | Fri, 13 Oct 2006 07:11:56 +0000 |
| Subject: | Re: array on addElement, does not work => QuickForm | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25428@lists.php.net to get a copy of this message | ||
Whooa!? HAHA, it worked. Wow, thanks a lot. My brains started to twist on
this awhile ago.
Yeah, that was my problem. I need to add the arrays together.
Louie
On 10/13/06, Ian Warner <iwarner@triangle-solutions.com> wrote:
Louie Miranda wrote: Im trying to add an array of year from addElement, but couldnt get what i wanted. My code below gets the current year and adds +10 to it and i loop it over an array of $numbers. // Get current year and add +10 more and display on the cc screen.-- Louie Miranda (lmiranda@gmail.com) http://www.axishift.com //JSM-WNo need for all of that: QuickForm has it all: $form->addElement('date', 'cc_expy', 'Card Expiry (Year)', array('format' => 'Y', 'minYear' => date('Y'), 'maxYear' => date('Y') + 10)); You problem was that you were overwriting you array each time anyway, you just had to add the arrays together. But use the above.$date_year = date('Y'); $date_year_nx_7years = ($date_year + 10); foreach (range($date_year, $date_year_nx_7years) as $number) {$num_array = array($number=>$number); //$num_array++;}But when i try to display it over to addElement, i ony see the last year which is "2016". Not the full loop. Does anybody know, how can i get this to work? Thanks a lot.$form->addElement('select', 'cc_expy', 'Card Expiry (Year)', $num_array); .. $form->toHtml()