Re: Dynamic Form Data

2010-03-23 Thread WebbedIT
To make things easier, lets strip this back to the core requirements
then you can add in your specific formatting afterwards

$form-input('User.country_id', array('empty' = '-- Select --'));
echo $ajax-observeField('UserCountryId', array('url' =
'countrySelect', 'update' = 'countryAction'));

This should trigger an ajax call to /app/users/countrySelect which
sets a $regions array and renders /app/view/users/country_select.ctp
using the ajax layout (you've obviously managed to get this far).  /
app/view/users/country_select.ctp view could look as simple as

$form-input('User.region_id', array('empty' = '-- Select --'));
echo $ajax-observeField('UserRegionId', array('url' =
'regionSelect', 'update' = 'regionAction'));

I have switched everything back to using cake's conventions, as it's
much easier to learn cake that way.

I imagine both the country and region fields are foreign_keys linking
to tables containing the Countries and Regions which are in turn
related to allow you to know which regions to show for which country
etc.  All foreign keys should have _id after them and form-input will
automagically look for a countries array if a field is called
country_id and a regions array for the field region_id.

HTH

Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: Dynamic Form Data

2010-03-23 Thread Ed Propsner
I actually ended up creating a .js file to hold my functions and initiated
my Ajax with 'onChange' = someFunction(); I pulled the field value into the
script and passed that into the controller action as a named param. etc.
etc. etc. (the entire process seemed a bit unnecessary and long-winded) The
bottom line is that it worked (for the field that was NOT created
dynamically). I repeated the process for the newly generated form field
which in turn did not work. No matter what I try I just can't retrieve any
data from form fields that get generated dynamically and thus the query
fails.

I'll take another wack at it using the suggestions you made and see how I
make out.

Yes, there are separate tables for country, state, and city. I believe I
have the associations set up correctly but who knows, I've been managing to
make a mess of everything else ;) Region and country are my foreign keys
however they are RegionID and CountryID in the db ... I'll change them to
region_id and country_id. The naming conventions in Cake take a little
getting used to.

On Tue, Mar 23, 2010 at 6:39 AM, WebbedIT p...@webbedit.co.uk wrote:

 To make things easier, lets strip this back to the core requirements
 then you can add in your specific formatting afterwards

 $form-input('User.country_id', array('empty' = '-- Select --'));
 echo $ajax-observeField('UserCountryId', array('url' =
 'countrySelect', 'update' = 'countryAction'));

 This should trigger an ajax call to /app/users/countrySelect which
 sets a $regions array and renders /app/view/users/country_select.ctp
 using the ajax layout (you've obviously managed to get this far).  /
 app/view/users/country_select.ctp view could look as simple as

 $form-input('User.region_id', array('empty' = '-- Select --'));
 echo $ajax-observeField('UserRegionId', array('url' =
 'regionSelect', 'update' = 'regionAction'));

 I have switched everything back to using cake's conventions, as it's
 much easier to learn cake that way.

 I imagine both the country and region fields are foreign_keys linking
 to tables containing the Countries and Regions which are in turn
 related to allow you to know which regions to show for which country
 etc.  All foreign keys should have _id after them and form-input will
 automagically look for a countries array if a field is called
 country_id and a regions array for the field region_id.

 HTH

 Paul.

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en

 To unsubscribe from this group, send email to cake-php+
 unsubscribegooglegroups.com or reply to this email with the words REMOVE
 ME as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: Dynamic Form Data

2010-03-23 Thread Ed Propsner
Okay, I managed to get things worked out. It's like anything else I suppose
... it just takes lots of experimenting, trial and error, and a whole lot of
getting used to before that little light comes on and things finally click.
Some things are finally making more sense to me now.

The documentation for Cake is a little vague in areas but that's nothing
new, it seems to be a common theme shared by anything actually worth using.
It gets better with time I suppose.

Thanks for the help. I'm sure I'll have plenty more questions as I try to
get situated with Cake.

On Tue, Mar 23, 2010 at 7:10 AM, Ed Propsner crotchf...@gmail.com wrote:

 I actually ended up creating a .js file to hold my functions and initiated
 my Ajax with 'onChange' = someFunction(); I pulled the field value into the
 script and passed that into the controller action as a named param. etc.
 etc. etc. (the entire process seemed a bit unnecessary and long-winded) The
 bottom line is that it worked (for the field that was NOT created
 dynamically). I repeated the process for the newly generated form field
 which in turn did not work. No matter what I try I just can't retrieve any
 data from form fields that get generated dynamically and thus the query
 fails.

 I'll take another wack at it using the suggestions you made and see how I
 make out.

 Yes, there are separate tables for country, state, and city. I believe I
 have the associations set up correctly but who knows, I've been managing to
 make a mess of everything else ;) Region and country are my foreign keys
 however they are RegionID and CountryID in the db ... I'll change them to
 region_id and country_id. The naming conventions in Cake take a little
 getting used to.

 On Tue, Mar 23, 2010 at 6:39 AM, WebbedIT p...@webbedit.co.uk wrote:

 To make things easier, lets strip this back to the core requirements
 then you can add in your specific formatting afterwards

 $form-input('User.country_id', array('empty' = '-- Select --'));
 echo $ajax-observeField('UserCountryId', array('url' =
 'countrySelect', 'update' = 'countryAction'));

 This should trigger an ajax call to /app/users/countrySelect which
 sets a $regions array and renders /app/view/users/country_select.ctp
 using the ajax layout (you've obviously managed to get this far).  /
 app/view/users/country_select.ctp view could look as simple as

 $form-input('User.region_id', array('empty' = '-- Select --'));
 echo $ajax-observeField('UserRegionId', array('url' =
 'regionSelect', 'update' = 'regionAction'));

 I have switched everything back to using cake's conventions, as it's
 much easier to learn cake that way.

 I imagine both the country and region fields are foreign_keys linking
 to tables containing the Countries and Regions which are in turn
 related to allow you to know which regions to show for which country
 etc.  All foreign keys should have _id after them and form-input will
 automagically look for a countries array if a field is called
 country_id and a regions array for the field region_id.

 HTH

 Paul.

 Check out the new CakePHP Questions site http://cakeqs.org and help
 others with their CakePHP related questions.

 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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en

 To unsubscribe from this group, send email to cake-php+
 unsubscribegooglegroups.com or reply to this email with the words REMOVE
 ME as the subject.




Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: Dynamic Form Data

2010-03-22 Thread WebbedIT
This is probably a mute point as you say your other sites are ajax
heavy, but what are you using to view the source.  I would suggest
something like FireBug as it shows the full source including DOM
changes via ajax/javascript.  It will also show you the results of
your ajax requests.  You should of course already be using something
similar to FireBug if you have been working with ajax a lot in the
past.

How have you set up a javascript event for the 1st dynamic field your
form creates?  My first guess is your adding an observer for the 2nd
field before it exists in the dom. You can also add an
'onchange'='jsfunction()' to the options array of form-input to add
events to your form fields, this would attach the event to the field
as it's created.

HTH

Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: Dynamic Form Data

2010-03-22 Thread Ed Propsner
Cake and MVC can be a bit daunting for the first time around especially when
having spent years with conventional code, nothing fancy. I re-wrote my Ajax
calls and the best I can say is that I didn't have something scripted
correctly the first time around because Chrome Java Console and FireBug both
now report that the element is indeed empty.

For the first field I am (was) using $ajax-observeField for field 1. In the
event that field 1 changed, it creates field 2 accordingly and so on down
the line with fields 3,4, etc.

I can tell you right off the bat that my problem is ignorance. This all
feels so alien to me.

I initially had it set up with onchange in the options array as you
suggested. I'm trying to stick with Cake conventions but my first
inclination was go straight for the head of my default.ctp and start with
script type= . . . new Ajax.Updater ... etc. Force of habit I
suppose. I'm a tad bit thrown off with controllers, actions, views, etc.
even though the concept does make sense. Let's say I did want to use
onchange ... where would I put the actual function and what syntax should
I use? This is the part that is throwing me off.


On Mon, Mar 22, 2010 at 5:13 AM, WebbedIT p...@webbedit.co.uk wrote:

 This is probably a mute point as you say your other sites are ajax
 heavy, but what are you using to view the source.  I would suggest
 something like FireBug as it shows the full source including DOM
 changes via ajax/javascript.  It will also show you the results of
 your ajax requests.  You should of course already be using something
 similar to FireBug if you have been working with ajax a lot in the
 past.

 How have you set up a javascript event for the 1st dynamic field your
 form creates?  My first guess is your adding an observer for the 2nd
 field before it exists in the dom. You can also add an
 'onchange'='jsfunction()' to the options array of form-input to add
 events to your form fields, this would attach the event to the field
 as it's created.

 HTH

 Paul

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en

 To unsubscribe from this group, send email to cake-php+
 unsubscribegooglegroups.com or reply to this email with the words REMOVE
 ME as the subject.




-- 
Please visit http://freecupidreport.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: Dynamic Form Data

2010-03-22 Thread Ed Propsner
Here is one thing I don't quite understand while using $ajax-observeField :

I created a dropdown populated with a list of countries like so ...

echo $html-tableCells(array('bCountry:/b', $form-input('country',
array($countries, 'empty' = '-- Select --', 'label' = '';
$options = array('url' = 'countrySelect','update' = 'countryAction');
echo $ajax-observeField('UserCountry', $options);

When a country is selected it does what I would expect and creates another
input for Region ...

echo $html-tableCells(array('bRegion:/b, $form-input('region',
array($regions, 'label' = '', 'empty' = '-- Select --';

The part I don't understand is that when I echo debug($regions) it displays
an array of regions as I intended however it is not populating the new
dropdown with the array.

If the script is making it far enough to go ahead and create the region
field and the $region array is not empty ... why would it not populate the
dropdown with the array ??


On Mon, Mar 22, 2010 at 5:05 PM, Ed Propsner crotchf...@gmail.com wrote:

 Cake and MVC can be a bit daunting for the first time around especially
 when having spent years with conventional code, nothing fancy. I re-wrote my
 Ajax calls and the best I can say is that I didn't have something scripted
 correctly the first time around because Chrome Java Console and FireBug both
 now report that the element is indeed empty.

 For the first field I am (was) using $ajax-observeField for field 1. In
 the event that field 1 changed, it creates field 2 accordingly and so on
 down the line with fields 3,4, etc.

 I can tell you right off the bat that my problem is ignorance. This all
 feels so alien to me.

 I initially had it set up with onchange in the options array as you
 suggested. I'm trying to stick with Cake conventions but my first
 inclination was go straight for the head of my default.ctp and start with
 script type= . . . new Ajax.Updater ... etc. Force of habit I
 suppose. I'm a tad bit thrown off with controllers, actions, views, etc.
 even though the concept does make sense. Let's say I did want to use
 onchange ... where would I put the actual function and what syntax should
 I use? This is the part that is throwing me off.


 On Mon, Mar 22, 2010 at 5:13 AM, WebbedIT p...@webbedit.co.uk wrote:

 This is probably a mute point as you say your other sites are ajax
 heavy, but what are you using to view the source.  I would suggest
 something like FireBug as it shows the full source including DOM
 changes via ajax/javascript.  It will also show you the results of
 your ajax requests.  You should of course already be using something
 similar to FireBug if you have been working with ajax a lot in the
 past.

 How have you set up a javascript event for the 1st dynamic field your
 form creates?  My first guess is your adding an observer for the 2nd
 field before it exists in the dom. You can also add an
 'onchange'='jsfunction()' to the options array of form-input to add
 events to your form fields, this would attach the event to the field
 as it's created.

 HTH

 Paul

 Check out the new CakePHP Questions site http://cakeqs.org and help
 others with their CakePHP related questions.

 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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en

 To unsubscribe from this group, send email to cake-php+
 unsubscribegooglegroups.com or reply to this email with the words REMOVE
 ME as the subject.




 --
 Please visit http://freecupidreport.com


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: Dynamic Form Data

2010-03-22 Thread xochitl reyes
hola ya cambie el mod-rewrite del apache y descomente una linea del core el
index principal de cake ya me sale con colores pero tengo mi primer archivo
.ctp en mis vistas pero no me sale nada grafico ni un error ni nada. solo me
sale reescrito todo el codigo que puse en ese archivo.
llevo todo el dia intentando solucionar ese problema k no tengo ni la mas
minima idea de porque  sea. alguien me puede ayudar ya no se que mas hacer o
k mas investigar ya tambien cambien el htaccess y eso que ni se para que es

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.