#5604: Form Helper mistake with chained Objects
---------------------------------------+------------------------------------
Reporter: neohunter | Type: Bug
Status: new | Priority: High
Milestone: 1.2.x.x | Component: Helpers
Version: RC3 | Severity: Major
Keywords: form helper formhelper | Php_version: PHP 5
Cake_version: |
---------------------------------------+------------------------------------
Hi, im developing an app with polls features. this is the DB estructure:
'''Polls''' hasMany '''Questions''' hasMany '''Options'''.
I want to create my form using the formHelper to add and edit the complete
poll in one single form.
before you can continue reading this you can check the problem on any View
and check the source (dont cares if the models doesnt exist) with:
{{{
echo $form->input("A.B.C");
echo $form->input("A.B.C.D");
echo $form->input("A.B.C.D.E");
}}}
check the source and see the last one dont have the rigth format.
now, this is the array that i want to fill in the form:
{{{
Array
(
[Poll] => Array
(
[id] => 3
[admins_id] => 0
[name] => Politica Industrial
[date] => 2008-10-13 07:53:13
[author] =>
)
[Question] => Array
(
[0] => Array
(
[id] => 1
[polls_id] => 3
[question] => Quien fue el precursor del
industrialismo
[Option] => Array
(
[0] => Array
(
[id] => 1
[questions_id] => 1
[option_select] => Jesus De Nazareth
[vote] =>
)
[1] => Array
(
[id] => 2
[questions_id] => 1
[option_select] => Henry Ford
[vote] =>
)
[2] => Array
(
[id] => 3
[questions_id] => 1
[option_select] => Jonathan Calderon
Roa
[vote] =>
)
)
)
)
)
}}}
is a small array cause is supose to have too many question and options as
the user wants.
the problem comes when i use this code:
{{{
//$q is from the question foreach and $o is from the option foreach, is a
incremental number
echo $form->input("Question.$q.Option.$o.option_select"); a foreach
}}}
that print:
{{{
<input .... name="data[Poll] ... >"
}}}
when it should print:
{{{
<input .... name="data[Poll][Question][0][Option][0][option_select] ... >
}}}
----
i dont want to edit the core to solve it but i read the following classes:
Form
View
App_Helper
Helper
from Core and i found that this happends because the '''setEntity'''
function from '''Helper''' (/cake/libs/view/helper.php) has a swith on the
372 line that
it just provides a depth of 4 possibilities in the data. So if we use the
formHelper to add an input with 5 or more elements will fail.
----
i tried to solve it adding an App_Helper on the app folder (the function
is called with '''parent::_initInputField($field, $options);''' from
FormHelper that next calls entity function from the same parent class) but
after i see the View Class i realy mess up =)... i already have it working
but i dont think is the rigth way, so i create this ticket!
--
Ticket URL: <https://trac.cakephp.org/ticket/5604>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets 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/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---