code/Forms/RemoteFileFormFactory.php
protected function getEditFormFields($context)
    {
        // Check if the url is valid
        $url = (isset($context['url'])) ? $context['url'] : null;
        if (empty($url)) {
            return $this->getCreateFormFields();
        }

        $url = trim($url);

        // Get embed
        $this->validateUrl($url);

        /** @var Embeddable $embed */
        $embed = Injector::inst()->create(Embeddable::class, $url);
        $this->validateEmbed($embed);

        // Build form
        $alignments = array(
            'leftAlone' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeftAlone', 'Left'),
            'center' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentCenter', 'Center'),
            'rightAlone' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRightAlone', 'Right'),
            'left' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeft', 'Left wrap'),
            'right' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRight', 'Right wrap'),
        );

        $width = $embed->getWidth();
        $height = $embed->getHeight();

        $fields = CompositeField::create([
            LiteralField::create(
                'Preview',
                sprintf(
                    '<img src="%s" class="%s" />',
                    $embed->getPreviewURL(),
                    'insert-embed-modal__preview'
                )
            )->addExtraClass('insert-embed-modal__preview-container'),
            HiddenField::create('PreviewUrl', 'PreviewUrl', $embed->getPreviewURL()),
            CompositeField::create([
                TextField::create('UrlPreview', $embed->getName(), $url)
                    ->setReadonly(true),
                HiddenField::create('Url', false, $url),
                TextField::create(
                    'CaptionText',
                    _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Caption', 'Caption')
                ),
                OptionsetField::create(
                    'Placement',
                    _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Placement', 'Placement'),
                    $alignments
                )
                    ->addExtraClass('insert-embed-modal__placement'),
                $dimensions = FieldGroup::create(
                    _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageSpecs', 'Dimensions'),
                    TextField::create('Width', '', $width)
                        ->setRightTitle(_t(
                            'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageWidth',
                            'Width'
                        ))
                        ->setMaxLength(5)
                        ->addExtraClass('flexbox-area-grow'),
                    TextField::create('Height', '', $height)
                        ->setRightTitle(_t(
                            'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageHeight',
                            'Height'
                        ))
                        ->setMaxLength(5)
                        ->addExtraClass('flexbox-area-grow')
                )->addExtraClass('fieldgroup--fill-width')
                    ->setName('Dimensions')
            ])->addExtraClass('flexbox-area-grow'),
        ])->addExtraClass('insert-embed-modal__fields--fill-width');

        if ($dimensions && $width && $height) {
            $ratio = $width / $height;

            $dimensions->setSchemaComponent('ProportionConstraintField');
            $dimensions->setSchemaState([
                'data' => [
                    'ratio' => $ratio
                ]
            ]);
        }
        return FieldList::create($fields);
    }
protected function getEditFormFields($context)
    {
        // Check if the url is valid
        $url = (isset($context['url'])) ? $context['url'] : null;
        if (empty($url)) {
            return $this->getCreateFormFields();
        }

        $url = trim($url);

        // Get embed
        $this->validateUrl($url);

        /** @var Embeddable $embed */
        $embed = Injector::inst()->create(Embeddable::class, $url);
        $this->validateEmbed($embed);

        // Build form
        $alignments = array(
            'leftAlone' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeftAlone', 'Left'),
            'center' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentCenter', 'Center'),
            'rightAlone' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRightAlone', 'Right'),
            'left' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeft', 'Left wrap'),
            'right' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRight', 'Right wrap'),
        );

        $width = $embed->getWidth();
        $height = $embed->getHeight();

        $fields = CompositeField::create([
            LiteralField::create(
                'Preview',
                sprintf(
                    '<img src="%s" class="%s" />',
                    $embed->getPreviewURL(),
                    'insert-embed-modal__preview'
                )
            )->addExtraClass('insert-embed-modal__preview-container'),
            HiddenField::create('PreviewUrl', 'PreviewUrl', $embed->getPreviewURL()),
            CompositeField::create([
                TextField::create('UrlPreview', $embed->getName(), $url)
                    ->setReadonly(true),
                HiddenField::create('Url', false, $url),
                TextField::create(
                    'CaptionText',
                    _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Caption', 'Caption')
                ),
                OptionsetField::create(
                    'Placement',
                    _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Placement', 'Placement'),
                    $alignments
                )
                    ->addExtraClass('insert-embed-modal__placement'),
                $dimensions = FieldGroup::create(
                    _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageSpecs', 'Dimensions'),
                    TextField::create('Width', '', $width)
                        ->setRightTitle(_t(
                            'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageWidth',
                            'Width'
                        ))
                        ->setMaxLength(5)
                        ->addExtraClass('flexbox-area-grow'),
                    TextField::create('Height', '', $height)
                        ->setRightTitle(_t(
                            'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageHeight',
                            'Height'
                        ))
                        ->setMaxLength(5)
                        ->addExtraClass('flexbox-area-grow')
                )->addExtraClass('fieldgroup--fill-width')
                    ->setName('Dimensions')
            ])->addExtraClass('flexbox-area-grow'),
        ])->addExtraClass('insert-embed-modal__fields--fill-width');

        if ($dimensions && $width && $height) {
            $ratio = $width / $height;

            $dimensions->setSchemaComponent('ProportionConstraintField');
            $dimensions->setSchemaState([
                'data' => [
                    'ratio' => $ratio
                ]
            ]);
        }
        return FieldList::create($fields);
    }
protected function getEditFormFields ( $ context ) { // Check if the url is valid $ url = ( isset ( $ context [ 'url' ] ) ) ? $ context [ 'url' ] : null ; if ( empty ( $ url ) ) { return $ this -> getCreateFormFields ( ) ; } $ url = trim ( $ url ) ; // Get embed $ this -> validateUrl ( $ url ) ; /** @var Embeddable $embed */ $ embed = Injector :: inst ( ) -> create ( Embeddable :: class , $ url ) ; $ this -> validateEmbed ( $ embed ) ; // Build form $ alignments = array ( 'leftAlone' => _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeftAlone' , 'Left' ) , 'center' => _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentCenter' , 'Center' ) , 'rightAlone' => _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRightAlone' , 'Right' ) , 'left' => _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeft' , 'Left wrap' ) , 'right' => _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRight' , 'Right wrap' ) , ) ; $ width = $ embed -> getWidth ( ) ; $ height = $ embed -> getHeight ( ) ; $ fields = CompositeField :: create ( [ LiteralField :: create ( 'Preview' , sprintf ( '<img src="%s" class="%s" />' , $ embed -> getPreviewURL ( ) , 'insert-embed-modal__preview' ) ) -> addExtraClass ( 'insert-embed-modal__preview-container' ) , HiddenField :: create ( 'PreviewUrl' , 'PreviewUrl' , $ embed -> getPreviewURL ( ) ) , CompositeField :: create ( [ TextField :: create ( 'UrlPreview' , $ embed -> getName ( ) , $ url ) -> setReadonly ( true ) , HiddenField :: create ( 'Url' , false , $ url ) , TextField :: create ( 'CaptionText' , _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Caption' , 'Caption' ) ) , OptionsetField :: create ( 'Placement' , _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Placement' , 'Placement' ) , $ alignments ) -> addExtraClass ( 'insert-embed-modal__placement' ) , $ dimensions = FieldGroup :: create ( _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageSpecs' , 'Dimensions' ) , TextField :: create ( 'Width' , '' , $ width ) -> setRightTitle ( _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageWidth' , 'Width' ) ) -> setMaxLength ( 5 ) -> addExtraClass ( 'flexbox-area-grow' ) , TextField :: create ( 'Height' , '' , $ height ) -> setRightTitle ( _t ( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageHeight' , 'Height' ) ) -> setMaxLength ( 5 ) -> addExtraClass ( 'flexbox-area-grow' ) ) -> addExtraClass ( 'fieldgroup--fill-width' ) -> setName ( 'Dimensions' ) ] ) -> addExtraClass ( 'flexbox-area-grow' ) , ] ) -> addExtraClass ( 'insert-embed-modal__fields--fill-width' ) ; if ( $ dimensions && $ width && $ height ) { $ ratio = $ width / $ height ; $ dimensions -> setSchemaComponent ( 'ProportionConstraintField' ) ; $ dimensions -> setSchemaState ( [ 'data' => [ 'ratio' => $ ratio ] ] ) ; } return FieldList :: create ( $ fields ) ; }
Get form fields for edit form

@param array $context
@return FieldList
@throws InvalidUrlException
Get form fields for edit form