@param null $id
@param null $fields

@return \SilverStripe\Forms\Form
327217
public function getEditForm($id = null, $fields = null)
    {
        $form = parent::getEditForm($id, $fields);

        $gridFieldName = $this->sanitiseClassName($this->modelClass);
        /** @var GridField $gridField */
        $gridField = $form->Fields()->fieldByName($gridFieldName);

        // GridField configuration
        /** @var GridFieldConfig $config */
        $config = $gridField->getConfig();

        // remove edit icon
        $config->removeComponentsByType(GridFieldEditButton::class);

        return $form;
    }
239859
public function getEditForm($id = null, $fields = null)
    {
        $form = parent::getEditForm($id, $fields);
        $grid_field = $form
            ->Fields()
            ->fieldByName($this->sanitiseClassName($this->modelClass));

        // Add bulk editing to gridfield
        $manager = new BulkManager();
        $manager->removeBulkAction(UnlinkHandler::class);

        $config = $grid_field->getConfig();

        $config
            ->removeComponentsByType(GridFieldPaginator::class)
            ->addComponent($manager)
            ->addComponent(new GridFieldConfigurablePaginator());

        // Switch to custom filter header
        $config
            ->removeComponentsByType(SSGridFieldFilterHeader::class)
            ->addComponent(new GridFieldFilterHeader(
                false,
                function ($context) {
                    $this->extend('updateSearchContext', $context);
                },
                function ($form) {
                    $this->extend('updateSearchForm', $form);
                }
            ));

        if (!$this->showSearchForm ||
            (is_array($this->showSearchForm) && !in_array($this->modelClass, $this->showSearchForm))
        ) {
            $config->removeComponentsByType(GridFieldFilterHeader::class);
        }

        if ($this->config()->auto_convert_dates) {
            GridFieldDateFinder::create($grid_field)->convertDateFields();
        }

        return $form;
    }
553330
public function run($id = null)
    {
        $app = $this->getApp();
        if ($app->getRequest()->getMethod() !== 'OPTIONS') {
            $app->getResponse()->setStatusCode(405);
        }
        $options = $id === null ? $this->collectionOptions : $this->resourceOptions;
        $app->getResponse()->getHeaderCollection()->set('Allow', implode(', ', $options));
        $app->getResponse()->getHeaderCollection()->set('Access-Control-Allow-Method', implode(', ', $options));
    }
925148
public function formAction($id, Request $request, $type = null)
    {
        $this->type = $type;

        return parent::formAction($id, $request);
    }
224468
public function edit(string $id = null)
    {
        $role = $this->Roles->get($id, [
            'contain' => ['Groups']
        ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $data = (array)$this->request->getData();
            /**
             * @var \RolesCapabilities\Model\Entity\Role
             */
            $role = $this->Roles->patchEntity($role, $data);
            // prepare associated capability records for creation
            if (!empty($data['capabilities'])) {
                $role->capabilities = $this->Roles->prepareCapabilities(
                    json_decode($data['capabilities'], true)
                );
            }
            // delete existing role capabilities
            $this->Roles->Capabilities->deleteAll(['role_id' => $id]);

            if ($this->Roles->save($role)) {
                $this->Flash->success((string)__('The role has been saved.'));

                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error((string)__('The role could not be saved. Please, try again.'));
            }
        }
        $groups = $this->Roles->Groups->find('list', ['limit' => 200]);
        // fetch role capabilities
        $roleCaps = $this->Roles->Capabilities->find('list')->where(['role_id' => $id])->toArray();

        $capabilities = $this->formatCapabilities(Utils::getAllCapabilities());

        $this->set(compact('role', 'groups', 'capabilities', 'roleCaps'));
        $this->set('_serialize', ['role']);
    }
1304378
public function getEditForm($id = null, $fields = null)
    {
        if (!$id) {
            $id = $this->currentPageID();
        }

        // Check record exists
        $record = $this->getRecord($id);
        if (!$record) {
            return $this->EmptyForm();
        }

        // Check if this record is viewable
        if ($record && !$record->canView()) {
            $response = Security::permissionFailure($this);
            $this->setResponse($response);
            return null;
        }

        $fields = $fields ?: $record->getCMSFields();
        if (!$fields) {
            throw new LogicException(
                "getCMSFields() returned null  - it should return a FieldList object.
                Perhaps you forgot to put a return statement at the end of your method?"
            );
        }

        // Add hidden fields which are required for saving the record
        // and loading the UI state
        if (!$fields->dataFieldByName('ClassName')) {
            $fields->push(new HiddenField('ClassName'));
        }

        $tree_class = $this->config()->get('tree_class');
        if ($tree_class::has_extension(Hierarchy::class)
            && !$fields->dataFieldByName('ParentID')
        ) {
            $fields->push(new HiddenField('ParentID'));
        }

        // Added in-line to the form, but plucked into different view by frontend scripts.
        if ($record instanceof CMSPreviewable) {
            /** @skipUpgrade */
            $navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator());
            $navField->setAllowHTML(true);
            $fields->push($navField);
        }

        if ($record->hasMethod('getAllCMSActions')) {
            $actions = $record->getAllCMSActions();
        } else {
            $actions = $record->getCMSActions();
            // add default actions if none are defined
            if (!$actions || !$actions->count()) {
                if ($record->hasMethod('canEdit') && $record->canEdit()) {
                    $actions->push(
                        FormAction::create('save', _t('SilverStripe\\CMS\\Controllers\\CMSMain.SAVE', 'Save'))
                            ->addExtraClass('btn btn-primary')
                            ->addExtraClass('font-icon-add-circle')
                    );
                }
                if ($record->hasMethod('canDelete') && $record->canDelete()) {
                    $actions->push(
                        FormAction::create('delete', _t('SilverStripe\\Admin\\ModelAdmin.DELETE', 'Delete'))
                            ->addExtraClass('btn btn-secondary')
                    );
                }
            }
        }

        $negotiator = $this->getResponseNegotiator();
        $form = Form::create(
            $this,
            "EditForm",
            $fields,
            $actions
        )->setHTMLID('Form_EditForm');
        $form->addExtraClass('cms-edit-form');
        $form->loadDataFrom($record);
        $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
        $form->setAttribute('data-pjax-fragment', 'CurrentForm');
        $form->setValidationResponseCallback(function (ValidationResult $errors) use ($negotiator, $form) {
            $request = $this->getRequest();
            if ($request->isAjax() && $negotiator) {
                $result = $form->forTemplate();

                return $negotiator->respond($request, array(
                    'CurrentForm' => function () use ($result) {
                        return $result;
                    }
                ));
            }
            return null;
        });

        // Announce the capability so the frontend can decide whether to allow preview or not.
        if ($record instanceof CMSPreviewable) {
            $form->addExtraClass('cms-previewable');
        }
        $form->addExtraClass('fill-height');

        // Add a default or custom validator.
        if ($record->hasMethod('getCMSValidator')) {
            $validator = $record->getCMSValidator();
            // The clientside (mainly LeftAndMain*.js) rely on ajax responses
            // which can be evaluated as javascript, hence we need
            // to override any global changes to the validation handler.
            if ($validator) {
                $form->setValidator($validator);
            }
        } else {
            $form->unsetValidator();
        }

        // Check if this form is readonly
        if (!$record->canEdit()) {
            $readonlyFields = $form->Fields()->makeReadonly();
            $form->setFields($readonlyFields);
        }
        return $form;
    }
1333779
public function getEditForm($id=null, $fields=null) {
        if(!$id) {
            $id=$this->currentPageID();
        }
        
        
        $record=$this->getRecord($id);
        if($record && !$record->canView()) {
            return Security::permissionFailure($this);
        }
        
        
        
        if($record) {
            $fields=$record->getCMSFields();
            $actions=new FieldList(
                                    FormAction::create('doSave', _t('CodeBank.SAVE', '_Save'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'),
                                    FormAction::create('doCancel', _t('CodeBank.CANCEL', '_Cancel'))
                                );
            
            
            if($record->canDelete()) {
                $actions->push(FormAction::create('doDelete', _t('CodeBank.DELETE', '_Delete'))->addExtraClass('ss-ui-action-destructive'));
            }
            
            
            // Use <button> to allow full jQuery UI styling
            $actionsFlattened=$actions->dataFields();
            if($actionsFlattened) {
                foreach($actionsFlattened as $action) {
                    if($action instanceof FormAction) {
                        $action->setUseButtonTag(true);
                    }
                }
            }
            
            
            if($record->hasMethod('getCMSValidator')) {
                $validator=$record->getCMSValidator();
            }else {
                $validator=new RequiredFields();
            }
            
            
            $fields->push(new HiddenField('ID', 'ID'));
            
            $form=CMSForm::create($this, 'EditForm', $fields, $actions, $validator)->setHTMLID('Form_EditForm');
            $form->loadDataFrom($record);
            $form->disableDefaultAction();
            $form->addExtraClass('cms-edit-form');
            $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
            $form->addExtraClass('center '.$this->BaseCSSClasses());
            $form->setResponseNegotiator($this->getResponseNegotiator());
            $form->setAttribute('data-pjax-fragment', 'CurrentForm');
            
            
            $this->extend('updateEditForm', $form);
            
            
            //Display message telling user to run dev/build because the version numbers are out of sync
            if(CB_VERSION!='@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version!=CB_VERSION.' '.CB_BUILD_DATE) {
                $form->insertBefore(new LiteralField('<p class="message error">'._t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink'=>'<a href="dev/build?flush=all">', 'endlink'=>'</a>')).'</p>'), 'LanguageID');
            }else if($this->hasOldTables()) {
                $form->insertBefore(new LiteralField('<p class="message warning">'._t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink'=>'<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink'=>'</a>')).'</p>'), 'LanguageID');
            }
            
            $form->Actions()->push(new LiteralField('CodeBankVersion', '<p class="codeBankVersion">Code Bank: '.$this->getVersion().'</p>'));
            
            
            Requirements::javascript(CB_DIR.'/javascript/CodeBank.EditForm.js');
            
            return $form;
        }
        
        $form=$this->EmptyForm();
        if(Session::get('CodeBank.deletedSnippetID')) {
            $form->Fields()->push(new HiddenField('ID', 'ID', Session::get('CodeBank.deletedSnippetID')));
        }
        
        
        //Display message telling user to run dev/build because the version numbers are out of sync
        if(CB_VERSION!='@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version!=CB_VERSION.' '.CB_BUILD_DATE) {
            $form->push(new LiteralField('<p class="message error">'._t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink'=>'<a href="dev/build?flush=all">', 'endlink'=>'</a>')).'</p>'));
        }else if($this->hasOldTables()) {
            $form->push(new LiteralField('<p class="message warning">'._t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink'=>'<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink'=>'</a>')).'</p>'));
        }
        
        $this->redirect('admin/codeBank/');
        return $form;
    }
210870
public static function create($id = null)
    {
        if ( empty($id) )
        {
            $id = md5(__METHOD__) . count(self::$instances); 
        }
        if ( empty(self::$instances[$id]) )
        {
            self::$instances[$id] = new self();  
        }
        return self::$instances[$id];
    }
260480
public final function findOne($id, $fields = '*') {
        if (is_array($id)) {
            $where = $id;
        } else {
            $idf   = $this->primaryKey;
            $where = [$idf => $id];
        }
        if (is_array($fields)) {
            $sql = $this->select(...$fields);
        } else {
            $sql = $this->select($fields);
        }
        $sql->where($where)->limit(0, 1);

        return $sql;
    }
415540
public function edit($id = null)
    {
        $photo = $this->Photos->get($id);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $photo = $this->Photos->patchEntity($photo, $this->request->getData());

            if ($this->Photos->save($photo)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index', $photo->album_id]);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('photo'));
    }
103979
public function removeFieldById($id)
    {
        foreach ($this->fields as $i => $field) {
            if ($field->getId() == $id) {
                unset($this->fields[$i]);
                break;
            }
        }

        return $this;
    }
251843
public function editAction($id = null)
    {
        $request = $this->getRequest();
        $this->manager = $this->getDoctrine()->getManager();
        // the key used to lookup the template
        $templateKey = 'edit';

        $id = $request->get($this->admin->getIdParameter());
        $object = $this->admin->getObject($id);

        if (!$object) {
            throw $this->createNotFoundException(sprintf('unable to find the object with id : %s', $id));
        }

        $this->admin->checkAccess('edit', $object);

        $preResponse = $this->preEdit($request, $object);
        if ($preResponse !== null) {
            return $preResponse;
        }

        $this->admin->setSubject($object);

        /** @var $form Form */
        $form = $this->admin->getForm();
        $form->setData($object);
        $form->handleRequest($request);

        $this->handleFiles($object);

        if ($form->isSubmitted()) {
            //TODO: remove this check for 3.0
            if (method_exists($this->admin, 'preValidate')) {
                $this->admin->preValidate($object);
            }
            $isFormValid = $form->isValid();

            // persist if the form was valid and if in preview mode the preview was approved
            if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
                try {
                    $object = $this->admin->update($object);

                    if ($this->isXmlHttpRequest()) {
                        return $this->renderJson(array(
                                    'result'     => 'ok',
                                    'objectId'   => $this->admin->getNormalizedIdentifier($object),
                                    'objectName' => $this->escapeHtml($this->admin->toString($object)),
                                        ), 200, array());
                    }

                    $this->addFlash(
                        'sonata_flash_success',
                        $this->admin->trans(
                            'flash_edit_success',
                            array('%name%' => $this->escapeHtml($this->admin->toString($object))),
                            'SonataAdminBundle'
                        )
                    );

                    // redirect to edit mode
                    return $this->redirectTo($object);
                } catch (ModelManagerException $e) {
                    $this->handleModelManagerException($e);

                    $isFormValid = false;
                } catch (LockException $e) {
                    $this->addFlash('sonata_flash_error', $this->admin->trans('flash_lock_error', array(
                                '%name%'       => $this->escapeHtml($this->admin->toString($object)),
                                '%link_start%' => '<a href="' . $this->admin->generateObjectUrl('edit', $object) . '">',
                                '%link_end%'   => '</a>',
                                    ), 'SonataAdminBundle'));
                }
            }

            // show an error message if the form failed validation
            if (!$isFormValid) {
                if (!$this->isXmlHttpRequest()) {
                    $this->addFlash(
                        'sonata_flash_error',
                        $this->admin->trans(
                            'flash_edit_error',
                            array('%name%' => $this->escapeHtml($this->admin->toString($object))),
                            'SonataAdminBundle'
                        )
                    );
                }
            } elseif ($this->isPreviewRequested()) {
                // enable the preview template if the form was valid and preview was requested
                $templateKey = 'preview';
                $this->admin->getShow();
            }
        }

        $view = $form->createView();

        // set the theme for the current Admin Form
        $this->defineFormTheme($view, $this->admin->getFormTheme());

        return $this->render($this->admin->getTemplate($templateKey), array(
                    'action' => 'edit',
                    'form'   => $view,
                    'object' => $object,
                        ), null);
    }
85247
public function postFields($id, array $fields, $guestSpaceId = null, $revision = -1): array
    {
        $options = ['json' => [
            'app' => $id,
            'properties' => $fields,
            'revision' => $revision
        ]];

        /** @var JsonStream $stream */
        $stream = $this->client
            ->post(KintoneApi::generateUrl('preview/app/form/fields.json', $guestSpaceId), $options)
            ->getBody();

        return $stream->jsonSerialize();
    }
91555
public function edit($id = null) {
		if (!$this->Cliente->exists($id)) {
			throw new NotFoundException(__('Invalid %s', Configure::read('Mesa.tituloCliente')));
		}
		if ($this->request->is(array('post', 'put'))) {
			if ($this->Cliente->save($this->request->data)) {
				$this->Session->setFlash(__('The %s has been saved.', Configure::read('Mesa.tituloCliente')));
				return $this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The %s could not be saved. Please, try again.', Configure::read('Mesa.tituloCliente')));
			}
		} else {
			$options = array('conditions' => array('Cliente.' . $this->Cliente->primaryKey => $id));
			$this->request->data = $this->Cliente->find('first', $options);
		}
		$descuentos = $this->Cliente->Descuento->find('list');
		$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
		$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
		$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
		$this->render('form');
	}
111826
public function select($table = null, $fields = null)
    {
        return $this->table($table)->select($fields);
    }
69252
public function getEditForm($id = null, $fields = null)
    {
        $form = parent::getEditForm($id, $fields);

        $definitionGridFieldName = $this->sanitiseClassName(WorkflowDefinition::class);

        // Show items submitted into a workflow for current user to action
        $fieldName = 'PendingObjects';
        $pending = $this->userObjects(Security::getCurrentUser(), $fieldName);

        if ($this->config()->fieldOverrides) {
            $displayFields = $this->config()->fieldOverrides;
        } else {
            $displayFields = array(
                'Title'          => _t('AdvancedWorkflowAdmin.Title', 'Title'),
                'LastEdited'     => _t('AdvancedWorkflowAdmin.LastEdited', 'Changed'),
                'WorkflowTitle'  => _t('AdvancedWorkflowAdmin.WorkflowTitle', 'Effective workflow'),
                'WorkflowStatus' => _t('AdvancedWorkflowAdmin.WorkflowStatus', 'Current action'),
            );
        }

        // Pending/Submitted items GridField Config
        $config = new GridFieldConfig_Base();
        $config->addComponent(new GridFieldEditButton());
        $config->addComponent(new GridFieldDetailForm());
        $config->getComponentByType(GridFieldPaginator::class)->setItemsPerPage(5);
        $columns = $config->getComponentByType(GridFieldDataColumns::class);
        $columns->setFieldFormatting($this->setFieldFormatting($config));

        if ($pending->count()) {
            $formFieldTop = GridField::create(
                $fieldName,
                $this->isAdminUser(Security::getCurrentUser()) ?
                    _t(
                        'AdvancedWorkflowAdmin.GridFieldTitleAssignedAll',
                        'All pending items'
                    ):
                    _t(
                        'AdvancedWorkflowAdmin.GridFieldTitleAssignedYour',
                        'Your pending items'
                    ),
                $pending,
                $config
            );

            $dataColumns = $formFieldTop->getConfig()->getComponentByType(GridFieldDataColumns::class);
            $dataColumns->setDisplayFields($displayFields);

            $formFieldTop->setForm($form);
            $form->Fields()->insertBefore($definitionGridFieldName, $formFieldTop);
        }

        // Show items submitted into a workflow by current user
        $fieldName = 'SubmittedObjects';
        $submitted = $this->userObjects(Security::getCurrentUser(), $fieldName);
        if ($submitted->count()) {
            $formFieldBottom = GridField::create(
                $fieldName,
                $this->isAdminUser(Security::getCurrentUser()) ?
                    _t(
                        'AdvancedWorkflowAdmin.GridFieldTitleSubmittedAll',
                        'All submitted items'
                    ):
                    _t(
                        'AdvancedWorkflowAdmin.GridFieldTitleSubmittedYour',
                        'Your submitted items'
                    ),
                $submitted,
                $config
            );

            $dataColumns = $formFieldBottom->getConfig()->getComponentByType(GridFieldDataColumns::class);
            $dataColumns->setDisplayFields($displayFields);

            $formFieldBottom->setForm($form);
            $formFieldBottom->getConfig()->removeComponentsByType(GridFieldEditButton::class);
            $formFieldBottom->getConfig()->addComponent(new GridFieldWorkflowRestrictedEditButton());
            $form->Fields()->insertBefore($definitionGridFieldName, $formFieldBottom);
        }

        $grid = $form->Fields()->fieldByName($definitionGridFieldName);
        if ($grid) {
            $grid->getConfig()->getComponentByType(GridFieldDetailForm::class)
                ->setItemEditFormCallback(function ($form) {
                    $record = $form->getRecord();
                    if ($record) {
                        $record->updateAdminActions($form->Actions());
                    }
                });

            $grid->getConfig()->getComponentByType(GridFieldDetailForm::class)
                ->setItemRequestClass(WorkflowDefinitionItemRequestClass::class);
            $grid->getConfig()->addComponent(new GridFieldExportAction());
            $grid->getConfig()->removeComponentsByType(GridFieldExportButton::class);
            $grid->getConfig()->removeComponentsByType(GridFieldImportButton::class);
        }

        $this->extend('updateEditFormAfter', $form);
        
        return $form;
    }
92135
public function edit($id = null)
    {
        $position = $this->BannersPositions->get($id);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $position = $this->BannersPositions->patchEntity($position, $this->request->getData());

            if ($this->BannersPositions->save($position)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('position'));
    }