[Formsess-devel] smarty_function_fs_input_checkbox and array name
Status: Beta
Brought to you by:
mrkatana
From: Raoul P. <pie...@wa...> - 2004-05-23 11:59:43
|
Hello, I'm testing the Formsess from Formsess-Trunck.tgz (23-01-04). When I try the input tag with type checkbox, and I use array as name, the values given in assign instruction are not used to generate checked attributs. Example : $_fs->assign('cb1', array(1,2), true); $_fs->assign('cb2', array('one'=>1,'tree'=>3), true); with <fs:input type="checkbox" name="cb1[]" value="1" /> <fs:input type="checkbox" name="cb2[tree]" value="3" /> and no checked tag... When I look at smarty_function_fs_input_checkbox, there is: if (isset($params['cb_offset'])) { // cb_offset: the getname is the name without the offset within the brackets at the end //we don't need that atm, because getValue needs the [] //$getname = substr($name, 0, (strlen($name) - 2 - strlen($params['cb_offset']))); $cb_offset = $params['cb_offset']; unset($params['cb_offset']); } //not need atm, see above //if (!isset($getname)) { // $getname = $name; // //must be changed later, to use $getname instead of name $item_value = $fs->getValue($name); so... But I don't understand why it's not possible to do it now. With: if (isset($params['cb_offset'])) { // cb_offset: the getname is the name without the offset within the brackets at the end //we don't need that atm, because getValue needs the [] // !? getValue doesn't work with "[...]" $cb_offset = $params['cb_offset']; $getname = substr($name, 0, (strlen($name) - 2 - strlen($cb_offset))); unset($params['cb_offset']); } else{ $getname = $name; } $item_value = $fs->getValue($getname); it seems OK. Regards Pierre |