We explained you a few days ago how to create lists of integers and
lists of month in a clean and automatic way thanks to Joomla API,
this article will explain you how to create fields of personalized
forms
Program of this second part:
Personalized options for your lists and radio buttons
Personalized lists
The buttons personalized radios
1) Personalized options for your lists and radio buttons :
This method turns over an object with two variables which are (by default) "text" et "value".
$value : It is the value which will be used in the HTML tag fot he value attribute
$text : It is the text which will be posted in HTML tag. If this parameter
is not indicated, it will take by default the value defined in $value
$value_name : It is the name which you can give to re-elect the value
variable. If this parameter is not indicated, the variable will be called
value.
$text_name : It is the name which you can give to re-elect the text variable. If
this parameter is not indicated the variable text will be called text
B - Code examples :
// Option and value have the same values, here names of city.
$citylist = array();
$citylist[] = mosHTML::makeOption( 'Paris' );
$citylist[] = mosHTML::makeOption( 'London' );
$citylist[] = mosHTML::makeOption( 'Berlin' );
// text is the name of the countries whereas been worth is a code on two characters
$countrylist = array();
$countrylist = mosHTML::makeOption( 'FR', 'France' );
$countrylist = mosHTML::makeOption( 'EN', 'England' );
$countrylist = mosHTML::makeOption( 'DE', 'Deutschland' );
// One starts by creating a virgin option which makes it possible to post a line "select an user"
// One adds new lines to the table thanks to array_merge, these data are
recovered since the data base by oblique lme of a request SQL
// text is the username stored in the base, been worth is the equivalent ID
$users = array();
$users[] = mosHTML::makeOption( '0', 'Select an user' );
$database->setQuery( "SELECT id AS value, username AS text FROM #__users" );
$users = array_merge( $users, $database->loadObjectList() );
$arr : It is a table of object which is created by the method mosHTML::
makeOption (with the possibility of using a request on a basis of data)
C'est un tableau d'objet qui est créé par la méthode mosHTML::makeOption (avec la possibilité d'utiliser une requete sur une base de données)
$tag_name : It is the attribute name list of buttons radios in HTML C'est l'attribut name de la liste de boutons radios en HTML
$tag_attribs : These is the additional attributes that one wants to assign with the buttons of the list.C'est les attributs supplémentaires que l'on veut assigner aux boutons de la liste.
$selected : It is the value of the button selected by defect C'est la valeur du bouton sélectionné par défaut
$key :It is the name which you can give to re-elect the been worth
variable. If this parameter is not renseign the variable will appelera
been worth.C'est le nom que vous pouvez donner pour renommer la variable "value". Si ce paramètre n'est pas renseign la variable s'appelera 'value'.
$text : It is the name which you can give to re-elect the variable text. If
this parameter is not renseign the variable text will appeleraC'est le nom que vous pouvez donner pour renommer la variable "text". Si ce paramètre n'est pas renseign la variable s'appelera text
NeoJoomla is not affiliated with or endorsed by the Joomla! Project or Open Source Matters. The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.