public function fesave()
    {
        $response        = StatusMessage::create("An unknown error has occured", StatusMessageTypes::DANGER);
        $response->model = new stdClass();
        $item            = FrontEndEditItem::createFromRequest();
        if ($item->exists()) {
            $record = $item->getRecord();
            if ($item->canEdit()) {
                if ($item->saveValue()) {
                    $response->setContent($item->field." saved ")->setType(StatusMessageTypes::SUCCESS);
                    $response->model = $record->toMap();
                } else {
                    $response->setContent("Error occurred while trying to save ".$item->field)->setType(StatusMessageTypes::DANGER);
                }
            } else {
                $response->setContent("You do not have permision to edit this item ".$item->field)->setType(StatusMessageTypes::DANGER);
            }
        } else {
            $response->setContent("Unable to locate ".$item->class." with id ".$item->id)->setType(StatusMessageTypes::DANGER);
        }
        /* @var $controller Controller */
        $controller = Controller::curr();
        if ($controller->getRequest()->isAjax()) {
            $controller->getResponse()->addHeader('Content-type', 'application/json');
            $response = Convert::raw2json($response->jsonSerialize());
        } else {
            $response = array("StatusMessage" => $response);
        }
        return $response;
    }
public function fesave()
    {
        $response        = StatusMessage::create("An unknown error has occured", StatusMessageTypes::DANGER);
        $response->model = new stdClass();
        $item            = FrontEndEditItem::createFromRequest();
        if ($item->exists()) {
            $record = $item->getRecord();
            if ($item->canEdit()) {
                if ($item->saveValue()) {
                    $response->setContent($item->field." saved ")->setType(StatusMessageTypes::SUCCESS);
                    $response->model = $record->toMap();
                } else {
                    $response->setContent("Error occurred while trying to save ".$item->field)->setType(StatusMessageTypes::DANGER);
                }
            } else {
                $response->setContent("You do not have permision to edit this item ".$item->field)->setType(StatusMessageTypes::DANGER);
            }
        } else {
            $response->setContent("Unable to locate ".$item->class." with id ".$item->id)->setType(StatusMessageTypes::DANGER);
        }
        /* @var $controller Controller */
        $controller = Controller::curr();
        if ($controller->getRequest()->isAjax()) {
            $controller->getResponse()->addHeader('Content-type', 'application/json');
            $response = Convert::raw2json($response->jsonSerialize());
        } else {
            $response = array("StatusMessage" => $response);
        }
        return $response;
    }
public function fesave ( ) { $ response = StatusMessage :: create ( "An unknown error has occured" , StatusMessageTypes :: DANGER ) ; $ response -> model = new stdClass ( ) ; $ item = FrontEndEditItem :: createFromRequest ( ) ; if ( $ item -> exists ( ) ) { $ record = $ item -> getRecord ( ) ; if ( $ item -> canEdit ( ) ) { if ( $ item -> saveValue ( ) ) { $ response -> setContent ( $ item -> field . " saved " ) -> setType ( StatusMessageTypes :: SUCCESS ) ; $ response -> model = $ record -> toMap ( ) ; } else { $ response -> setContent ( "Error occurred while trying to save " . $ item -> field ) -> setType ( StatusMessageTypes :: DANGER ) ; } } else { $ response -> setContent ( "You do not have permision to edit this item " . $ item -> field ) -> setType ( StatusMessageTypes :: DANGER ) ; } } else { $ response -> setContent ( "Unable to locate " . $ item -> class . " with id " . $ item -> id ) -> setType ( StatusMessageTypes :: DANGER ) ; } /* @var $controller Controller */ $ controller = Controller :: curr ( ) ; if ( $ controller -> getRequest ( ) -> isAjax ( ) ) { $ controller -> getResponse ( ) -> addHeader ( 'Content-type' , 'application/json' ) ; $ response = Convert :: raw2json ( $ response -> jsonSerialize ( ) ) ; } else { $ response = array ( "StatusMessage" => $ response ) ; } return $ response ; }
saves the DBField value, called with an ajax request
@return bool
saves the DBField value called with an ajax request