Monday, March 30, 2009

Re: Cake PHP 1.2 - Need Help For Posting Mulitple Checkboxes

Hi Miles,

Thanks for your needful help.

But currently i am developing company product through pure cakephp
1.2 standards and i have to follow its conventions during whole
development cycle.

currently i have created multiple check boxes using $form->select()
with 'multiple'=>'checkbox' options.

For these reasons, i have three alternate for this solution in which
i will prevent to generate these hidden controls while displaying
multiple check boxes as below:

(1) First way is pass extra boolean parameter say $showHidden=true /
false

based on above parameter i will hide line no#: 1190 from file
cake library helper "form.php".
this line is executed from "select" Function.

(2) Second way is that in same file "form.php" and "select" Function
on line No: 1187,

the variable $style get its value based on 'multiple' key and
value attributes if it is 'checkbox' then stored same value otherwise
null.

so i can use this $style variable as conditional variable for
generating hidden control or not.

Means instead line no: 1190 as below:
$select[] = $this->hidden(null, array('value' => '', 'id' => null,
'secure' => false));

i will change it as below:

if($style!='checkbox'){

$select[] = $this->hidden(null, array('value' => '', 'id' =>
null, 'secure' => false));
}


(3) Third way is alternate way of above but in different way.

If we don't want any changes directly to "select" Function of
Form.php library helper file, Then

- Just copy this "select" Function and Paste Above or below this
function.
- Now, rename this function from "select" To say it "selectMultiple
( )" function.
- Then, put/change above line no:1190 with a condition of $style as
displayed on 2nd way.


i can apply any of one among above alternatives through this way it
will not auto generate hidden for multiple check boxes and post values
with correct array that i want.

But even though i think this not standard way that i should follow.

so please let me know your ideas....

Best Regards,
Keyur Vaghani.
------------------------------------------------

On Mar 30, 12:11 pm, Miles J <mileswjohn...@gmail.com> wrote:
> The only alternative is doing it manually.
>
> <input type="checkbox" name="data[Model][field][]">
>
> You are unable to do it with the form helper.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: