We have a plugin (let’s name it “Cms”). This plugin has a model called Image, used to add images to a model. The Image model is inside the plugin; others models are, of course, outside (for example the “Page” model). The relationship is made on the fly, with a code like this
$this->Page->bindModel(array('hasMany' => array('Cms.Image' => array ('foreignKey' => 'record_id')))); We use Cms.Image because the bind must be donde like: Plugin.Model Then we want to add a new page, so we write this code in the “add” view echo $form->create(array('type' => 'file')); echo $form->input('Page.title'); echo $form->input('Page.content'); ...etc And now, here is the problem: ¿How do we write the input for the Image? If the Image model where outside the plugin, we would normally use: echo $form->input('Image.0.name'); then in the controller we use the method saveAll, and everything is smooth. But the situation is different here, we have a model outside the plugin (Page) which is associated with a model Inside the plugin (Image) My first attempt was to do this: echo $form->input('Cms.Image.0.name'); but it fails! It generates an input with the attribute name="data[Cms] [Image][0][name]" If I hardcode the input field with something like name="data[Cms.Image] [0][name]" everything works perfect (with validation and callbacks for both models). But working in this way I have to do an extra job for display error messages and I assume I would have some other issues if I don’t use the form helper. The second idea was: echo $form->input('Image.0.name', array('plugin' => 'Cms')); But it didn’t work either, because the input method in the form helper doesn’t expect a plugin key in the options array and just ignore it. I read the code of Form::input() and I found that the separation into array keys by the point is made by a very parent classes, so I neither could easily hack the core to find a solution. What do yo think? Is there a way to solve this issue or the problem is me misunderstanding something? (or everything maybe) Thanks for the support! --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---