I am creating a website that requires several forms for the same model in different quantities on one page. These forms belong to the object with id. Currently, since I cannot figure out how to change form identifiers, I am stuck in a bunch of duplicate identifiers.
I am looking for a way to add an object identifier to a form identifier so that they are not invalid. I prefer to write my own javascript, so I will not use the ajax helper.
<?php
?>
<div id="objects">
<?php foreach($objects as $object): ?>
<div class="object">
<?php echo "this is object {$object['Object']['id']}"?>
<?php
echo $this->element('object_comments_loop', array('comments' => $object['Object']['Comments']);
?>
<div class="comment">
<?php
echo $form->create('Comment', array('url' => array('controller' => 'comments', 'action' => 'createComment'));
echo $form->hidden('object_id', array('value' => $object['Object']['id']));
echo $form->input('comment_body', array('label' => __('comment', true), 'type' => 'text'));
echo $form->end(__('comment_submit', true));
?>
</div>
</div>
<?php endforeach; ?>
</div>
source
share