src/Ubiquity/controllers/crud/CRUDController.php
public function update() {
		$message = new CRUDMessage ( "Modifications were successfully saved", "Updating" );
		$instance = $_SESSION ["instance"] ?? null;
		if (isset ( $instance )) {
			$isNew = $instance->_new;
			try {
				$updated = CRUDHelper::update ( $instance, $_POST );
				if ($updated) {
					$message->setType ( "success" )->setIcon ( "check circle outline" );
					$message = $this->_getEvents ()->onSuccessUpdateMessage ( $message, $instance );
					$this->refreshInstance ( $instance, $isNew );
				} else {
					$message->setMessage ( "An error has occurred. Can not save changes." )->setType ( "error" )->setIcon ( "warning circle" );
					$message = $this->_getEvents ()->onErrorUpdateMessage ( $message, $instance );
				}
			} catch ( \Exception $e ) {
				$instanceString = $this->getInstanceToString ( $instance );
				$message = new CRUDMessage ( "Exception : can not update `" . $instanceString . "`", "Exception", "warning", "warning" );
				$message = $this->_getEvents ()->onErrorUpdateMessage ( $message, $instance );
			}
			echo $this->_showSimpleMessage ( $message, "updateMsg" );
			echo $this->jquery->compile ( $this->view );
			return $instance;
		} else {
			throw new \Exception ( '$_SESSION["instance"] is null' );
		}
	}
public function update() {
		$message = new CRUDMessage ( "Modifications were successfully saved", "Updating" );
		$instance = $_SESSION ["instance"] ?? null;
		if (isset ( $instance )) {
			$isNew = $instance->_new;
			try {
				$updated = CRUDHelper::update ( $instance, $_POST );
				if ($updated) {
					$message->setType ( "success" )->setIcon ( "check circle outline" );
					$message = $this->_getEvents ()->onSuccessUpdateMessage ( $message, $instance );
					$this->refreshInstance ( $instance, $isNew );
				} else {
					$message->setMessage ( "An error has occurred. Can not save changes." )->setType ( "error" )->setIcon ( "warning circle" );
					$message = $this->_getEvents ()->onErrorUpdateMessage ( $message, $instance );
				}
			} catch ( \Exception $e ) {
				$instanceString = $this->getInstanceToString ( $instance );
				$message = new CRUDMessage ( "Exception : can not update `" . $instanceString . "`", "Exception", "warning", "warning" );
				$message = $this->_getEvents ()->onErrorUpdateMessage ( $message, $instance );
			}
			echo $this->_showSimpleMessage ( $message, "updateMsg" );
			echo $this->jquery->compile ( $this->view );
			return $instance;
		} else {
			throw new \Exception ( '$_SESSION["instance"] is null' );
		}
	}
public function update ( ) { $ message = new CRUDMessage ( "Modifications were successfully saved" , "Updating" ) ; $ instance = $ _SESSION [ "instance" ] ?? null ; if ( isset ( $ instance ) ) { $ isNew = $ instance -> _new ; try { $ updated = CRUDHelper :: update ( $ instance , $ _POST ) ; if ( $ updated ) { $ message -> setType ( "success" ) -> setIcon ( "check circle outline" ) ; $ message = $ this -> _getEvents ( ) -> onSuccessUpdateMessage ( $ message , $ instance ) ; $ this -> refreshInstance ( $ instance , $ isNew ) ; } else { $ message -> setMessage ( "An error has occurred. Can not save changes." ) -> setType ( "error" ) -> setIcon ( "warning circle" ) ; $ message = $ this -> _getEvents ( ) -> onErrorUpdateMessage ( $ message , $ instance ) ; } } catch ( \ Exception $ e ) { $ instanceString = $ this -> getInstanceToString ( $ instance ) ; $ message = new CRUDMessage ( "Exception : can not update `" . $ instanceString . "`" , "Exception" , "warning" , "warning" ) ; $ message = $ this -> _getEvents ( ) -> onErrorUpdateMessage ( $ message , $ instance ) ; } echo $ this -> _showSimpleMessage ( $ message , "updateMsg" ) ; echo $ this -> jquery -> compile ( $ this -> view ) ; return $ instance ; } else { throw new \ Exception ( '$_SESSION["instance"] is null' ) ; } }
Updates an instance from the data posted in a form

@return object The updated instance
Updates an instance from the data posted in a form