I did a bit of playing around with Ajax in Cake and was able to extract
field values using Prototype (it's just as easy to use JQuery or Mootools
with Cake 1.3).

Instead of using $ajax->observeField I used onChange="" in my combo passing
in the id of element I wanted to update and the action I wanted to use for
the url. I was using it to "pre-validate" passwords and although I no longer
use it it did exactly what I wanted.

Here is an example:

*view:*

$form->input('confirm_password', array( 'type' => 'password', 'onChange'
=>'checkPass(\'passOkay\', \'confirmPassword/id1:\');' ));

*.js** *

function checkPass(id, url)
{
var pw1 = Form.Element.getValue('UserPassword');
var pw2 = Form.Element.getValue('UserConfirmPassword');
var ext = '/id2:'+pw2;
new Ajax.Updater(id,url +pw1+ext,{asynchronous:true});
}

*controller:*

function confirmPassword()
{
$pw1 = $this->params['named']['id1'];
$pw2 = $this->params['named']['id2'];
$pwarray = array($pw1, $pw2);
$this->set('pwmatch', $pwarray);
}

>From there I was able to access my form values in confirm_password.ctp via
$pwmatch array. I was simply displaying messages based on the contents of
the array but you could do whatever you like with the data inside the
controller before passing it along.

I'm new to Cake and that was my first attempt at extracting values from a
form but it worked just fine.

HTH,

- Ed


On Wed, Apr 28, 2010 at 2:28 AM, MANOJ DHAMAL <[email protected]>wrote:

> Hi,
> I am using three combobox in .ctp file.
> Like
> <?php echo $form->select('category_id',$category_options,
> $category_selected,array('id'=>'category','class'=>'search_input'),false);
> ?
> >
>
> <?php echo $form->select('type_id',$type_options,
> $type_selected,array('class'=>'search_input'),false); ?>
>
> <?php echo $form->select('sortby_id',
> $sort_by,null,array('id'=>'sortby'),false); ?>
>
> For third combo i m using ajax, so i used observeField method to find
> change at state of third combo which calls action
> sort_property_searchresult like..
>
> <?php echo $ajax->observeField('sortby',array('url'=>'/properties/
> sort_property_searchresult','update'=>'property_showcase_table'));?>
>
> At sort_property_searchresult() i want fetch values of all comboboxes
> like
>
>  $category=$this->data['Property']['category_id'];
>
>  $type=$this->data['Property']['type_id'];
>
> $sortbyvalue=$this->data['Property']['sortby_id'];
>
> But i found value of $sortbyvalue, so please tell me how to fetch
> values of all comboboxes? Thanks..
>
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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 [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