I am trying to display contact information and allow edit in place. It is not updating the field. Basically, the div I want to use has (e.g.) an address, I click on it, it highlight and then an edit box appears, I edit, click ok, and the thing updates as success. Yet the data has not updated, which I can tell when I check the record.
Here are snippets of relevant code:
CONTROLLER:
var $helpers = array ('Html','Form','Ajax','Javascript','Menu');
var $components = array( 'RequestHandler');
var $name = 'People';
…
function edit_in_place() {
if (!empty($this->data)) {
if ($this->Person->save($this->data)) {
$thisId=$this->Person->id;
$this->header("Content-Type: application/json");
echo 'success';
exit;
} else {
return 'Fail';
}
}
$this->Autorender = FALSE;
exit;
}
VIEW THAT TRIGGERS EDIT_IN_PLACE:
<div id="addresswork">
<?php echo $person['Person']['addresswork'] ?>
</div>
<?php
echo $ajax->editor(
"addresswork", array(
'controller'=>'People',
'action'=>'edit_in_place',
$person['Person']['id']
),
array('highlightcolor'=>'#aaeeff')
)
?>
I have tried finding good documentation on this and failed. Any suggestions?
I got it working — the problem was I wasn’t getting data into the function in the controller as I expected. So I did a print_r to figure out what params were coming back. Here’s what I did, although I’d be interested in any more comments on the correct way to do it:
In the view that triggers this, I did this: