pnForm
[ class tree: pnForm ] [ index: pnForm ] [ all elements ]

Class: pnFormDropdownList

Source Location: /system/pnForm/plugins/function.pnformdropdownlist.php

Class Overview

pnFormPlugin
   |
   --pnFormStyledPlugin
      |
      --pnFormBaseListSelector
         |
         --pnFormDropdownList

Drop down list


Author(s):

Version:

  • $Id: pnversion.php 19260 2006-06-12 13:08:15Z markwest $

Copyright:

  • (c) 2007, Zikula Development Team

Variables

Methods


Child classes:

pnFormCategorySelector
Category selector
pnFormLanguageSelector
Language selector

Inherited Variables

Inherited Methods


Class Details

[line 95]
Drop down list

Renders an HTML <select> element with the supplied items.

You can set the items directly like this:

  1.  <!--[pnformdropdownlist id="mylist" items=$items]-->
with the form event handler code like this:
  1.  class mymodule_user_testHandler extends pnFormHandler
  2.  {
  3.    function initialize(&$render)
  4.    {
  5.        $items arrayarray('text' => 'A''value' => '1'),
  6.                        array('text' => 'B''value' => '2'),
  7.                        array('text' => 'C''value' => '3') );
  8.  
  9.        $render->assign('items'$items)// Supply items
  10.        $render->assign('mylist'2);     // Supply selected value
  11.    }
  12.  }
Or you can set them indirectly using the plugin's databased features:
  1.  <!--[pnformdropdownlist id="mylist"]-->
with the form event handler code like this:
  1.  class mymodule_user_testHandler extends pnFormHandler
  2.  {
  3.    function initialize(&$render)
  4.    {
  5.        $items arrayarray('text' => 'A''value' => '1'),
  6.                        array('text' => 'B''value' => '2'),
  7.                        array('text' => 'C''value' => '3') );
  8.  
  9.        $render->assign('mylistItems'$items);  // Supply items
  10.        $render->assign('mylist'2);            // Supply selected value
  11.    }
  12.  }

Selected index is zero based. Selected value is a string - and the PHP null value is also a valid value.

Option groups can be added by setting an 'optgroup' attribute on each item. For instance:

  1.  class mymodule_user_testHandler extends pnFormHandler
  2.  {
  3.    function initialize(&$render)
  4.    {
  5.        $items arrayarray('text' => 'A''value' => '1''optgroup' => 'AAA'),
  6.                        array('text' => 'B''value' => '2''optgroup' => 'BBB'),
  7.                        array('text' => 'C''value' => '3''optgroup' => 'CCC') );
  8.  
  9.        $render->assign('mylistItems'$items);  // Supply items
  10.        $render->assign('mylist'2);            // Supply selected value
  11.    }
  12.  }

You can also encourage reuse of dropdown lists by inheriting from the dropdown list into a specialized list a'la MyCategorySelector or MyColorSelector, and then use this plugin where ever you want a category or color selector. In this way you don't have to remember to assign the items to the render every time you need such a selector. In these plugins you must set the items in the load event handler. See pnFormLanguageSelector for a good example of how this can be done.




Tags:

version:  $Id: pnversion.php 19260 2006-06-12 13:08:15Z markwest $
copyright:  (c) 2007, Zikula Development Team


[ Top ]


Class Variables

$autoPostBack =

[line 135]

Enable or disable auto postback

Auto postback means "generate a server side event when selected index changes". If enabled then the event handler named in $onSelectedIndexChanged will be fired in the main form event handler.



Type:   bool


[ Top ]

$onSelectedIndexChanged =  'handleSelectedIndexChanged'

[line 171]

Name of selected index changed method



Tags:

var:  Default is "handleSelectedIndexChanged"

Type:   string


[ Top ]

$saveAsString =

[line 163]

Enable saving of multiple selected values as a colon delimited string

Enable this to save the selected values as a single string instead of an array of selected values. The result is a colon separated string like ":10:20:30".



Type:   bool


[ Top ]

$selectedIndex =

[line 125]

Selected item index

You can assign to this in your templates like:

  1.    <!--[pnformdropdownlist selectedIndex=2]-->
But in your code you should use pnFormDropdownList::setSelectedIndex() and pnFormDropdownList::getSelectedIndex().

Select index is not valid when selectionMode=multiple.




Tags:

var:  Zero based index

Type:   int


[ Top ]

$selectedValue =

[line 110]

Selected value

You can assign to this in your templates like:

  1.    <!--[pnformdropdownlist selectedValue=B]-->
But in your code you should use pnFormDropdownList::setSelectedValue() and pnFormDropdownList::getSelectedValue().

Selected value is an array of values if you have set selectionMode=multiple.



Type:   mixed


[ Top ]

$selectionMode =  'single'

[line 145]

Selection mode

Sets selection mode to either single item selection (standard dropdown) or multiple item selection.




Tags:

var:  Possible values are 'single' and 'multiple'

Type:   string


[ Top ]

$size =  null

[line 153]

Size of dropdown

This corresponds to the "size" attribute of the HTML <select> element.



Type:   int


[ Top ]



Class Methods


method create [line 180]

void create( &$render, $params)



Overrides pnFormBaseListSelector::create() (parent method not documented)

Parameters:

   &$render  
   $params  

[ Top ]

method decode [line 280]

void decode( &$render)



Overrides pnFormPlugin::decode() (Decode event handler)

Parameters:

   &$render  

[ Top ]

method getFilename [line 174]

void getFilename( )



Overridden in child classes as:

pnFormCategorySelector::getFilename()
pnFormLanguageSelector::getFilename()

Overrides pnFormBaseListSelector::getFilename() (parent method not documented)

[ Top ]

method getSelectedIndex [line 385]

void getSelectedIndex( )



[ Top ]

method getSelectedValue [line 361]

void getSelectedValue( )



Overrides pnFormBaseListSelector::getSelectedValue() (parent method not documented)

[ Top ]

method load [line 187]

void load( &$render, &$params)



Overridden in child classes as:

pnFormCategorySelector::load()
pnFormLanguageSelector::load()

Overrides pnFormBaseListSelector::load() (parent method not documented)

Parameters:

   &$render  
   &$params  

[ Top ]

method raisePostBackEvent [line 272]

void raisePostBackEvent( &$render, $eventArgument)



Parameters:

   &$render  
   $eventArgument  

[ Top ]

method render [line 200]

void render( &$render)



Overridden in child classes as:

pnFormCategorySelector::render()

Overrides pnFormPlugin::render() (Render event handler)

Parameters:

   &$render  

[ Top ]

method setSelectedIndex [line 375]

void setSelectedIndex( $index)



Parameters:

   $index  

[ Top ]

method setSelectedValue [line 316]

void setSelectedValue( $value)



Overrides pnFormBaseListSelector::setSelectedValue() (parent method not documented)

Parameters:

   $value  

[ Top ]

method validate [line 305]

void validate( &$render)



Parameters:

   &$render  

[ Top ]


Documentation generated on Fri, 18 Jul 2008 21:45:49 +0200 by phpDocumentor 1.4.1