7.1.2.6 observeField
observeField(string $field, array $options)
Observes the field with the DOM id specified by $field (every $options['frequency'] seconds) and makes an XMLHttpRequest when its contents have changed.
When no frequency or a small frequency interval (between 0 and 1) is specified, a prototype Form.Element.EventObserver will be used instead of a Form.Element.Observer.
The Form.Element.EventObserver is not timed and will execute at the same time the value of the element has changed.
<?php echo $form->create( 'Post' ); ?>
<?php $titles = array( 1 => 'Tom', 2 => 'Dick', 3 => 'Harry' ); ?>
<?php echo $form->input( 'title', array( 'options' => $titles ) ) ?>
</form>
<?php
echo $ajax->observeField( 'PostTitle',
array(
'url' => array( 'action' => 'edit' ),
'frequency' => 0.2,
)
);
?>
<?php echo $form->create( 'Post' ); ?><?php $titles = array( 1 => 'Tom', 2 => 'Dick', 3 => 'Harry' ); ?><?php echo $form->input( 'title', array( 'options' => $titles ) ) ?></form><?phpecho $ajax->observeField( 'PostTitle',array('url' => array( 'action' => 'edit' ),'frequency' => 0.2,));?>
observeField uses the same options as link
The field to send up can be set using $options['with']. This defaults to Form.Element.serialize('$field'). Data submitted is available at $this->data inside your controllers. Callbacks can be used with this function.
To send up the entire form when the field changes use $options['with'] = Form.serialize( $('Form ID') )


























