0

I am trying to categorise checkboxes with category|productname values. I need to use the cakephp form helper so I am somewhat clueless as to how to do that. I tried to use an array as the input name, but I am getting a lot of errors:

 // Current code:
 $this->Form->input(array("catname","prodname"),array(....)

 // Expected for html:
 <input name="data[formname][catname][prodname]" ... ">

Any ideas on how to do this?

2 Answers 2

4

You can use:

$this->Form->input('formname.catname.prodname', ...);
Sign up to request clarification or add additional context in comments.

5 Comments

@FinnWea Which CakePHP version do you use?
I am using CakePHP v2.4
@FinnWea I just tested it with v2.4.1, and this snippet works fine here, i.e. it creates the HTML code the OP expected in the question.
Mmm, thats strange, I used $this->Form->input('test', array('name' => 'data[test][0]'); for now.
@FinnWea Hm, I don't understand what you are trying to accomplish, but did you check the documentation of the FormHelper (book.cakephp.org/2.0/en/core-libraries/helpers/form.html)?
0

I am trying the same, I just figured out that you can print arrays with helpers this way

// Current code:
 $this->Form->input('Model.0.object');

For example, if you have 10 objects related to this model, that will print the first one, same for 1, 2 etc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.