You would have to use a custom model to overwrite some functionality
(cake 1.x):
E.g

class MyHtml extends Html
{
   ...
   function setFormTag($tagValue) {
      $parts = explode("/", $tagValue);

      $this->model = $parts[0];
      $this->field    = array_pop($parts);

      // We add a class attribute to indicate the index of the model
      if (count($parts) > 1)
         $this->modelIndex = $parts[1];
      else
         $this->modelIndex = null;
   }

   ...
   function tagValue($fieldName) {
      $this->setFormTag($fieldName);
      if ($this->modelIndex !== null)
      {
         // This assumes that your data is like so:
         // data = array('Model'=>array(array('Model'=>array(/* data
*/)))); // Default cake
         // which can be obtained with $this->data['Model'] = $this-
>Model->findAll();

         if (isset($this->params['data'][$this->model][$this-
>modelIndex][$this->model][$this->field])) {
            return h($this->params['data'][$this->model][$this-
>modelIndex][$this->model][$this->field]);
         } elseif(isset($this->data[$this->model][$this->modelIndex]
[$this->model][$this->field])) {
            return h($this->data[$this->model][$this->modelIndex]
[$this->model][$this->field]);
         }
      }
      else
      {
         return parent::tagValue($fieldName);
      }
   }
   ...
}


In your view, you can then do the following:

<?php foreach ($this->data['Product'] as $i => $rec) : ?>

      <tr>
         <td><?= $rec['Product']['name'] ?></td>
         <td><?= $myhtml->input("Product/$i/qty") ?></td>
      </tr>

<?php endforeach; ?>

Please note that this code was not tested.
Also, the id of your input will become Product0Qty, Product1Qty, etc.

Please contribute your final solution. There are many with the same
issue :S.

Thanks.

Dimitry Z


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to