public function updateEditForm(Form $form)
    {
        Requirements::javascript('symbiote/silverstripe-advancedworkflow:client/dist/js/advancedworkflow.js');
        /** @var WorkflowService $service */
        $service = singleton(WorkflowService::class);
        /** @var DataObject|WorkflowApplicable $record */
        $record = $form->getRecord();
        $active = $service->getWorkflowFor($record);

        if ($active) {
            $fields = $form->Fields();
            $current = $active->CurrentAction();
            $wfFields = $active->getWorkflowFields();

            $allowed = array_keys($wfFields->saveableFields());
            $data = [];
            foreach ($allowed as $fieldName) {
                $data[$fieldName] = $current->$fieldName;
            }

            $fields->findOrMakeTab(
                'Root.WorkflowActions',
                _t('Workflow.WorkflowActionsTabTitle', 'Workflow Actions')
            );
            $fields->addFieldsToTab('Root.WorkflowActions', $wfFields);

            $form->loadDataFrom($data);

            // Set the form to readonly if the current user doesn't have permission to edit the record, and/or it
            // is in a state that requires review
            if (!$record->canEditWorkflow() && !$fields->isReadonly()) {
                $fields->makeReadonly();
            }

            $this->owner->extend('updateWorkflowEditForm', $form);
        }
    }
public function updateEditForm(Form $form)
    {
        Requirements::javascript('symbiote/silverstripe-advancedworkflow:client/dist/js/advancedworkflow.js');
        /** @var WorkflowService $service */
        $service = singleton(WorkflowService::class);
        /** @var DataObject|WorkflowApplicable $record */
        $record = $form->getRecord();
        $active = $service->getWorkflowFor($record);

        if ($active) {
            $fields = $form->Fields();
            $current = $active->CurrentAction();
            $wfFields = $active->getWorkflowFields();

            $allowed = array_keys($wfFields->saveableFields());
            $data = [];
            foreach ($allowed as $fieldName) {
                $data[$fieldName] = $current->$fieldName;
            }

            $fields->findOrMakeTab(
                'Root.WorkflowActions',
                _t('Workflow.WorkflowActionsTabTitle', 'Workflow Actions')
            );
            $fields->addFieldsToTab('Root.WorkflowActions', $wfFields);

            $form->loadDataFrom($data);

            // Set the form to readonly if the current user doesn't have permission to edit the record, and/or it
            // is in a state that requires review
            if (!$record->canEditWorkflow() && !$fields->isReadonly()) {
                $fields->makeReadonly();
            }

            $this->owner->extend('updateWorkflowEditForm', $form);
        }
    }
public function updateEditForm ( Form $ form ) { Requirements :: javascript ( 'symbiote/silverstripe-advancedworkflow:client/dist/js/advancedworkflow.js' ) ; /** @var WorkflowService $service */ $ service = singleton ( WorkflowService :: class ) ; /** @var DataObject|WorkflowApplicable $record */ $ record = $ form -> getRecord ( ) ; $ active = $ service -> getWorkflowFor ( $ record ) ; if ( $ active ) { $ fields = $ form -> Fields ( ) ; $ current = $ active -> CurrentAction ( ) ; $ wfFields = $ active -> getWorkflowFields ( ) ; $ allowed = array_keys ( $ wfFields -> saveableFields ( ) ) ; $ data = [ ] ; foreach ( $ allowed as $ fieldName ) { $ data [ $ fieldName ] = $ current -> $ fieldName ; } $ fields -> findOrMakeTab ( 'Root.WorkflowActions' , _t ( 'Workflow.WorkflowActionsTabTitle' , 'Workflow Actions' ) ) ; $ fields -> addFieldsToTab ( 'Root.WorkflowActions' , $ wfFields ) ; $ form -> loadDataFrom ( $ data ) ; // Set the form to readonly if the current user doesn't have permission to edit the record, and/or it // is in a state that requires review if ( ! $ record -> canEditWorkflow ( ) && ! $ fields -> isReadonly ( ) ) { $ fields -> makeReadonly ( ) ; } $ this -> owner -> extend ( 'updateWorkflowEditForm' , $ form ) ; } }
Need to update the edit form AFTER it's been transformed to read only so that the workflow stuff is still
allowed to be added with 'write' permissions

@param Form $form
Need to update the edit form AFTER it s been transformed to read only so that the workflow stuff is still allowed to be added with write permissions