Infrastructure/BaseEntity/DatabaseTable/View/DatabaseTableView.php
public function updateView(Request $request, Response $response, $args)
    {
        $primaryKeyValue = $args[ROUTEARG_PRIMARY_KEY];

        // make sure there is a record for the mapper
        if (null === $record = $this->tableMapper->selectForPrimaryKey($primaryKeyValue)) {
            return $this->databaseRecordNotFound($response, $primaryKeyValue, $this->tableMapper, 'update');
        }

        $formFieldData = ($request->isPut() && isset($args[SlimPostgres::USER_INPUT_KEY])) ? $args[SlimPostgres::USER_INPUT_KEY] : $record;

        $form = new DatabaseTableForm($this->tableMapper, $this->router->pathFor(SlimPostgres::getRouteName(true, $this->routePrefix, 'update', 'put'), [ROUTEARG_PRIMARY_KEY => $primaryKeyValue]), $this->csrf->getTokenNameKey(), $this->csrf->getTokenName(), $this->csrf->getTokenValueKey(), $this->csrf->getTokenValue(), 'update', $formFieldData);
        
        FormHelper::unsetSessionFormErrors();

        return $this->view->render(
            $response,
            'Admin/form.php',
            [
                'title' => 'Update ' . $this->tableMapper->getFormalTableName(false),
                'form' => $form,
                'primaryKey' => $primaryKeyValue,
                'navigationItems' => $this->navigationItems,
                'hideFocus' => true
            ]
        );
    }
public function updateView(Request $request, Response $response, $args)
    {
        $primaryKeyValue = $args[ROUTEARG_PRIMARY_KEY];

        // make sure there is a record for the mapper
        if (null === $record = $this->tableMapper->selectForPrimaryKey($primaryKeyValue)) {
            return $this->databaseRecordNotFound($response, $primaryKeyValue, $this->tableMapper, 'update');
        }

        $formFieldData = ($request->isPut() && isset($args[SlimPostgres::USER_INPUT_KEY])) ? $args[SlimPostgres::USER_INPUT_KEY] : $record;

        $form = new DatabaseTableForm($this->tableMapper, $this->router->pathFor(SlimPostgres::getRouteName(true, $this->routePrefix, 'update', 'put'), [ROUTEARG_PRIMARY_KEY => $primaryKeyValue]), $this->csrf->getTokenNameKey(), $this->csrf->getTokenName(), $this->csrf->getTokenValueKey(), $this->csrf->getTokenValue(), 'update', $formFieldData);
        
        FormHelper::unsetSessionFormErrors();

        return $this->view->render(
            $response,
            'Admin/form.php',
            [
                'title' => 'Update ' . $this->tableMapper->getFormalTableName(false),
                'form' => $form,
                'primaryKey' => $primaryKeyValue,
                'navigationItems' => $this->navigationItems,
                'hideFocus' => true
            ]
        );
    }
public function updateView ( Request $ request , Response $ response , $ args ) { $ primaryKeyValue = $ args [ ROUTEARG_PRIMARY_KEY ] ; // make sure there is a record for the mapper if ( null === $ record = $ this -> tableMapper -> selectForPrimaryKey ( $ primaryKeyValue ) ) { return $ this -> databaseRecordNotFound ( $ response , $ primaryKeyValue , $ this -> tableMapper , 'update' ) ; } $ formFieldData = ( $ request -> isPut ( ) && isset ( $ args [ SlimPostgres :: USER_INPUT_KEY ] ) ) ? $ args [ SlimPostgres :: USER_INPUT_KEY ] : $ record ; $ form = new DatabaseTableForm ( $ this -> tableMapper , $ this -> router -> pathFor ( SlimPostgres :: getRouteName ( true , $ this -> routePrefix , 'update' , 'put' ) , [ ROUTEARG_PRIMARY_KEY => $ primaryKeyValue ] ) , $ this -> csrf -> getTokenNameKey ( ) , $ this -> csrf -> getTokenName ( ) , $ this -> csrf -> getTokenValueKey ( ) , $ this -> csrf -> getTokenValue ( ) , 'update' , $ formFieldData ) ; FormHelper :: unsetSessionFormErrors ( ) ; return $ this -> view -> render ( $ response , 'Admin/form.php' , [ 'title' => 'Update ' . $ this -> tableMapper -> getFormalTableName ( false ) , 'form' => $ form , 'primaryKey' => $ primaryKeyValue , 'navigationItems' => $ this -> navigationItems , 'hideFocus' => true ] ) ; }
this can be called for both the initial get and the posted form if errors exist (from controller)
this can be called for both the initial get and the posted form if errors exist ( from controller )