Model/CommonAppModel.php
public function edit($id, $data) {
		$record = $this->read(null, $id);
		if (!$record) {
			throw new OutOfBoundsException('view.fail');
		}

		if (empty($data)) {
			return;
		}

		$data[$this->alias] = array_merge(
			array_diff_key($data[$this->alias], $record[$this->alias]),
			array_diff($data[$this->alias], $record[$this->alias])
		);

		$validate = $this->validate;
		foreach (array_keys($this->validate) as $field) {
			if (!isset($data[$this->alias][$field])) {
				unset($this->validate[$field]);
			}
		}

		$this->id = $id;
		$this->data = $data;

		$result = $this->save(null, false);

		$this->validate = $validate;
		$this->data = Hash::merge($record, $result);

		if (!$result) {
			return false;
		}

		$this->triggerEvent('Model.' . $this->name . '.afterEdit', $this);
		return $data;
	}
public function edit($id, $data) {
		$record = $this->read(null, $id);
		if (!$record) {
			throw new OutOfBoundsException('view.fail');
		}

		if (empty($data)) {
			return;
		}

		$data[$this->alias] = array_merge(
			array_diff_key($data[$this->alias], $record[$this->alias]),
			array_diff($data[$this->alias], $record[$this->alias])
		);

		$validate = $this->validate;
		foreach (array_keys($this->validate) as $field) {
			if (!isset($data[$this->alias][$field])) {
				unset($this->validate[$field]);
			}
		}

		$this->id = $id;
		$this->data = $data;

		$result = $this->save(null, false);

		$this->validate = $validate;
		$this->data = Hash::merge($record, $result);

		if (!$result) {
			return false;
		}

		$this->triggerEvent('Model.' . $this->name . '.afterEdit', $this);
		return $data;
	}
public function edit ( $ id , $ data ) { $ record = $ this -> read ( null , $ id ) ; if ( ! $ record ) { throw new OutOfBoundsException ( 'view.fail' ) ; } if ( empty ( $ data ) ) { return ; } $ data [ $ this -> alias ] = array_merge ( array_diff_key ( $ data [ $ this -> alias ] , $ record [ $ this -> alias ] ) , array_diff ( $ data [ $ this -> alias ] , $ record [ $ this -> alias ] ) ) ; $ validate = $ this -> validate ; foreach ( array_keys ( $ this -> validate ) as $ field ) { if ( ! isset ( $ data [ $ this -> alias ] [ $ field ] ) ) { unset ( $ this -> validate [ $ field ] ) ; } } $ this -> id = $ id ; $ this -> data = $ data ; $ result = $ this -> save ( null , false ) ; $ this -> validate = $ validate ; $ this -> data = Hash :: merge ( $ record , $ result ) ; if ( ! $ result ) { return false ; } $ this -> triggerEvent ( 'Model.' . $ this -> name . '.afterEdit' , $ this ) ; return $ data ; }
Common edit operation.

@param string $id Model record's primary key value.
@param array $data New model record's data.
@return boolean
@throws OutOfBoundsException If the record does not exist.
Common edit operation .