Dear all,
I am having a problem with radio boxes in CakePhP - specifically $this-
>request->data is not holding the values that the user inputs when the
page is reloaded; e.g. when the form has invalid inputs. This is a
considerable problem because its a very large form. Code is here:
http://bin.cakephp.org/view/1065399785. (Ugly code, please don't lynch
me.)

So the problem is mostly to do with FormHelper and radio button inputs
but it may also be to do with 'not doing things the right way' or 'the
cake way'. Perhaps some background would help... The client has been
very clear about what the registration form should like and has
specified between 2 and 3 dozen inputs of the kind, e.g., 'Do you have
heart problems? [Yes/No] Please give details: [textarea]'.  To avoid
data inconsistency (what if they click 'no' but then proceed to give
details of their heart problems?) I made the decision early on to only
record heart_problem_details as a nullable text field in the database.
If the field is null, we can assume the user does not have heart
problems...

So I made a function to print out a radio button using FormHelper
along with some Jquery to show/hide the container div and empty the
text input. Not the most elegent way to do it.. and as a result
neither the model nor the database has a has_heart_problems field as
in this example.

Questions:

-Is $this->request->data not holding the values that the user inputs
because FormHelper is being called from within a function, or because
there is no corresponding field in the database or model?
-Is there a better / more cake way to achieve this functionality than
with a function in the view?
-Is it strictly nessesary that the model be aware of the fields used
in $this->Form-> etc. in the view? Can individual fields in the model
be decoupled from the database? Would this solve the problem?
-Was the decision not to hold most booleans in the database a bad
design idea? Would you reccomend I refactor the database to hold the
booleans? What about data inconsistency (.e.g user answers 'no' to
'has_heart_problems', then types a value into
'heart_problems_details'?

Full working copy of code here: http://eventsafetyalliance.co.uk/register
(from page 5 onwards)

All the best,

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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

Reply via email to