Following Problem:

Imagine that you have two tables to work on, for example "associates"
and "documents". So you want to give the associate a name, but also
want to give the document a name. The only difference is that the name
of the associate can be multiline, while the document's can't.

So you write:
echo $form->create('Document');
echo $form->input('Associate.name');
echo $form->input('Document.name');
echo $form->end('save');

Both fields are <input type="text "/> fields. But that's not the
expected behaviour.

When reading the core form.php library, I found out that the model
definition for the "main model" (the one given in create()) is saved
in the formhelper itself. When calling input() with no type
definition, the formhelper tries to match the fieldName with the field
structure saved.

In this case the field "name" is found in the table structure, and
given to the type "text", while "textarea" would be the correct
value.

Fix for this:

- save the default model name on form creation (around line 109)
                        // fix
                        $this->defaultModel = $model;
- check if the given model is the default model on input creation
(around line 560)
   replace                      } elseif (isset($this->fieldset['fields'][$this-
>field()])) {
   with                                         } elseif (isset($this-
>fieldset['fields'][$this->field()]) && $this->model() == $this-
>defaultModel) {


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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