c5 form helpers

Permalink
I am new to php and form helpers I am trying to build a edit page and would like to do so using these helpers...

I am trying to layout 3 unchecked boxes with a label
<?php echo $form->label('vtype', 'Vehicle Types');?>
<?php echo $form->checkbox('vtype', 'New', 'False', array('style' => 'width: 320px'));?>
<?php echo $form->checkbox('vtype', 'Used', 'False', array('style' => 'width: 320px'));?>
<?php echo $form->checkbox('vtype', 'Certified', 'False', array('style' => 'width: 320px'));?>


What am I doing wrong. thx

 
ScottC replied on at Permalink Reply
ScottC
$vtypeArray = array('New','Used,'Certified);

echo $form->select('vtype',$vtypeArray,$vtype);

i'd use a select unless you really want to use the checkbox helper and need multiple values selected. I find em kinda limiting and I have a mental block against how they do the checkbox checked stuff :)

Otherwise, you'd want to look at form checkbox but you'd want to set up all the vtypes with a [] setting them as an array to be able to check the post array for which of that array type are present and thus selected. Not necessarily best to learn php with a framework, check out Larry Ulman's PHP books.

-Scott
aaron replied on at Permalink Reply
thx makes sense...
aaron replied on at Permalink Reply
how would I make it a multiple select?
<select name="" multiple></select>
<?php $vtypeArray = array('New','Used','Certified');
   echo $form->select('vtype',$vtypeArray,$vtype, array('style' => 'width: 320px')); ?>


I am not really trying to learn php as much as I am trying to set up the forms and views for my dev guys I just thought I would try and learn how these helpers worked...
ScottC replied on at Permalink Reply
ScottC
you'd need to then just figure out multi-select which off the top of my head i don't know the syntax for, but since it is html based I assume it is a lot like a a dropdown.

Your dev guys should be able to do this in their sleep though, I use checkbox groups and check the post array and group them based on the name so like select name=whatever[18] and then in the post array they show up under whatever and whatever was checked is there, from 0-18 i guess.