Get Smarty

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

html_checkboxes

Nome do Atributo Tipo Obrigatório Padrão Descrição
name string Não checkbox O nome da lista checkbox
values array Sim, a menos que estaja usando o atributo options n/a Uma matriz de valores para os botões checkbox
output array Sim, a menos que estaja usando o atributo options n/a uma matriz de saída para os botões checkbox
selected string/array Não empty O(s) elemento(s) checkbox marcado(s)
options matriz Sim, a menos que esteja usando values e output n/a Uma matriz associativa de valores e saída
separator string Não empty string de texto para separar cada checkbox
labels boolean Não true Adicionar tags <label> para na saída

html_checkboxes é uma função personalizada que cria um grupo de checkbox com os dados fornecidos. Ela cuida de qual(is) item(s) estão selecionado(s) por padrão. Os atributos obrigatórios são values e output, a menos que você use options. Toda a saída é compatível com XHTML.

Todos os parâmetro que não estejam na lista acima são mostrados como pares nome/valor dentro de cada tag <input> criada.

Example 8.6. html_checkboxes


index.php:

require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane Johnson','Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');


index.tpl:

{html_checkboxes values=$cust_ids checked=$customer_id output=$cust_names separator="<br />"}


index.php:

require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_checkboxes', array(
			1000 => 'Joe Schmoe',
			1001 => 'Jack Smith',
			1002 => 'Jane Johnson',
			1003 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');

index.tpl:

{html_checkboxes name="id" options=$cust_checkboxes checked=$customer_id separator="<br />"}


MOSTRA: (ambos os exemplos)

<label><input type="checkbox" name="checkbox[]" value="1000" />Joe Schmoe</label><br />
<label><input type="checkbox" name="checkbox[]" value="1001" checked="checked" />Jack Smith</label><br />
<label><input type="checkbox" name="checkbox[]" value="1002" />Jane Johnson</label><br />
<label><input type="checkbox" name="checkbox[]" value="1003" />Charlie Brown</label><br />


Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 0 plus 2? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com
ASP.NET hosting @aspnethosting.co.uk