code/Controller/AssetAdmin.php
protected function getAbstractFileForm($id, $name, $context = [])
    {
        /** @var File $file */
        $file = File::get()->byID($id);

        if (!$file) {
            $this->jsonError(404);
            return null;
        }

        if (!$file->canView()) {
            $this->jsonError(403, _t(
                __CLASS__.'.ErrorItemPermissionDenied',
                "You don't have the necessary permissions to modify {ObjectTitle}",
                [ 'ObjectTitle' => $file->i18n_singular_name() ]
            ));
            return null;
        }

        // Pass to form factory
        $showLinkText = $this->getRequest()->getVar('requireLinkText');
        $augmentedContext = array_merge(
            $context,
            [ 'Record' => $file, 'RequireLinkText' => isset($showLinkText) ]
        );
        $scaffolder = $this->getFormFactory($file);
        $form = $scaffolder->getForm($this, $name, $augmentedContext);

        // Set form action handler with ID included
        $form->setRequestHandler(
            LeftAndMainFormRequestHandler::create($form, [ $id ])
        );

        // Configure form to respond to validation errors with form schema
        // if requested via react.
        $form->setValidationResponseCallback(function (ValidationResult $error) use ($form, $id, $name) {
            $schemaId = Controller::join_links($this->Link('schema'), $name, $id);
            return $this->getSchemaResponse($schemaId, $form, $error);
        });

        return $form;
    }
protected function getAbstractFileForm($id, $name, $context = [])
    {
        /** @var File $file */
        $file = File::get()->byID($id);

        if (!$file) {
            $this->jsonError(404);
            return null;
        }

        if (!$file->canView()) {
            $this->jsonError(403, _t(
                __CLASS__.'.ErrorItemPermissionDenied',
                "You don't have the necessary permissions to modify {ObjectTitle}",
                [ 'ObjectTitle' => $file->i18n_singular_name() ]
            ));
            return null;
        }

        // Pass to form factory
        $showLinkText = $this->getRequest()->getVar('requireLinkText');
        $augmentedContext = array_merge(
            $context,
            [ 'Record' => $file, 'RequireLinkText' => isset($showLinkText) ]
        );
        $scaffolder = $this->getFormFactory($file);
        $form = $scaffolder->getForm($this, $name, $augmentedContext);

        // Set form action handler with ID included
        $form->setRequestHandler(
            LeftAndMainFormRequestHandler::create($form, [ $id ])
        );

        // Configure form to respond to validation errors with form schema
        // if requested via react.
        $form->setValidationResponseCallback(function (ValidationResult $error) use ($form, $id, $name) {
            $schemaId = Controller::join_links($this->Link('schema'), $name, $id);
            return $this->getSchemaResponse($schemaId, $form, $error);
        });

        return $form;
    }
protected function getAbstractFileForm ( $ id , $ name , $ context = [ ] ) { /** @var File $file */ $ file = File :: get ( ) -> byID ( $ id ) ; if ( ! $ file ) { $ this -> jsonError ( 404 ) ; return null ; } if ( ! $ file -> canView ( ) ) { $ this -> jsonError ( 403 , _t ( __CLASS__ . '.ErrorItemPermissionDenied' , "You don't have the necessary permissions to modify {ObjectTitle}" , [ 'ObjectTitle' => $ file -> i18n_singular_name ( ) ] ) ) ; return null ; } // Pass to form factory $ showLinkText = $ this -> getRequest ( ) -> getVar ( 'requireLinkText' ) ; $ augmentedContext = array_merge ( $ context , [ 'Record' => $ file , 'RequireLinkText' => isset ( $ showLinkText ) ] ) ; $ scaffolder = $ this -> getFormFactory ( $ file ) ; $ form = $ scaffolder -> getForm ( $ this , $ name , $ augmentedContext ) ; // Set form action handler with ID included $ form -> setRequestHandler ( LeftAndMainFormRequestHandler :: create ( $ form , [ $ id ] ) ) ; // Configure form to respond to validation errors with form schema // if requested via react. $ form -> setValidationResponseCallback ( function ( ValidationResult $ error ) use ( $ form , $ id , $ name ) { $ schemaId = Controller :: join_links ( $ this -> Link ( 'schema' ) , $ name , $ id ) ; return $ this -> getSchemaResponse ( $ schemaId , $ form , $ error ) ; } ) ; return $ form ; }
Abstract method for generating a form for a file

@param int $id Record ID
@param string $name Form name
@param array $context Form context
@return Form|HTTPResponse
Abstract method for generating a form for a file