Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I create multiple forms on a single page in CakePHP?
    primarykey
    data
    text
    <p>I'm trying to come up with a standard way to create multiple forms for the same model on an index page. Here's a little more detail.</p> <p>I have a list of binders, each with a memo being displayed. I would like the memo fields to be editable from the index page. Obviously it doesn't work to just copy and paste the view for the edit_memo action, like so:</p> <pre><code>&lt;?php echo $this-&gt;Form-&gt;create('Binder');?&gt; &lt;fieldset&gt; &lt;legend&gt;&lt;?php __('Edit Memo'); ?&gt;&lt;/legend&gt; &lt;?php echo $this-&gt;Form-&gt;input('id'); echo $this-&gt;Form-&gt;input('memo'); ?&gt; &lt;/fieldset&gt; &lt;?php echo $this-&gt;Form-&gt;end(__('Submit', true));?&gt; </code></pre> <p>But that's essentially what I'm looking to do. In context, I'm just looping through the binders in the index action and the memos are part of the model.</p> <p>I've tried changing <code>$this-&gt;Form-&gt;create('Binder')</code> to the following:</p> <pre><code>$this-&gt;Form-&gt;create(null,array( 'id'=&gt;"BinderEditMemo.$i", 'controller' =&gt; 'binders', 'action' =&gt; 'edit_memo', 'id' =&gt; $binder['Binder']['id'] )); </code></pre> <p>But no luck. The memo field still gets the regular id, so I think I might need to change that as well. When I submit the form it does perform the action, however it does not save. FYI, I have routed the id parameter to the action in my routes. </p> <p>I'm sure there has to be a standard way to render multiple forms in the index loop. Any thoughts?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload