original_string: public function configure($id)
      {
          $instance = $this->_getOrThrow($id, ['locked' => false]);
          $arrayContext = [
              'schema' => [],
              'defaults' => [],
              'errors' => [],
          ];
  
          if ($this->request->data()) {
              $instance->accessible('*', true);
              $instance->accessible(['id', 'eav_attribute', 'handler', 'ordering'], false);
  
              foreach ($this->request->data as $k => $v) {
                  if (str_starts_with($k, '_')) {
                      $instance->set(str_replace_once('_', '', $k), $v);
                      unset($this->request->data[$k]);
                  }
              }
  
              $validator = $this->FieldInstances->validator('settings');
              $instance->validateSettings($this->request->data(), $validator);
              $errors = $validator->errors($this->request->data(), false);
  
              if (empty($errors)) {
                  $instance->set('settings', $this->request->data());
                  $save = $this->FieldInstances->save($instance);
  
                  if ($save) {
                      $this->Flash->success(__d('field', 'Field information was saved.'));
                      $this->redirect($this->referer());
                  } else {
                      $this->Flash->danger(__d('field', 'Your information could not be saved.'));
                  }
              } else {
                  $this->Flash->danger(__d('field', 'Field settings could not be saved.'));
                  foreach ($errors as $field => $message) {
                      $arrayContext['errors'][$field] = $message;
                  }
              }
          } else {
              $arrayContext['defaults'] = (array)$instance->settings;
              $this->request->data = $arrayContext['defaults'];
          }
  
          $this->title(__d('field', 'Configure Field'));
          $this->set(compact('arrayContext', 'instance'));
      }
code: public function configure($id)
      {
          $instance = $this->_getOrThrow($id, ['locked' => false]);
          $arrayContext = [
              'schema' => [],
              'defaults' => [],
              'errors' => [],
          ];
  
          if ($this->request->data()) {
              $instance->accessible('*', true);
              $instance->accessible(['id', 'eav_attribute', 'handler', 'ordering'], false);
  
              foreach ($this->request->data as $k => $v) {
                  if (str_starts_with($k, '_')) {
                      $instance->set(str_replace_once('_', '', $k), $v);
                      unset($this->request->data[$k]);
                  }
              }
  
              $validator = $this->FieldInstances->validator('settings');
              $instance->validateSettings($this->request->data(), $validator);
              $errors = $validator->errors($this->request->data(), false);
  
              if (empty($errors)) {
                  $instance->set('settings', $this->request->data());
                  $save = $this->FieldInstances->save($instance);
  
                  if ($save) {
                      $this->Flash->success(__d('field', 'Field information was saved.'));
                      $this->redirect($this->referer());
                  } else {
                      $this->Flash->danger(__d('field', 'Your information could not be saved.'));
                  }
              } else {
                  $this->Flash->danger(__d('field', 'Field settings could not be saved.'));
                  foreach ($errors as $field => $message) {
                      $arrayContext['errors'][$field] = $message;
                  }
              }
          } else {
              $arrayContext['defaults'] = (array)$instance->settings;
              $this->request->data = $arrayContext['defaults'];
          }
  
          $this->title(__d('field', 'Configure Field'));
          $this->set(compact('arrayContext', 'instance'));
      }
code_tokens: public function configure ( $ id ) { $ instance = $ this -> _getOrThrow ( $ id , [ 'locked' => false ] ) ; $ arrayContext = [ 'schema' => [ ] , 'defaults' => [ ] , 'errors' => [ ] , ] ; if ( $ this -> request -> data ( ) ) { $ instance -> accessible ( '*' , true ) ; $ instance -> accessible ( [ 'id' , 'eav_attribute' , 'handler' , 'ordering' ] , false ) ; foreach ( $ this -> request -> data as $ k => $ v ) { if ( str_starts_with ( $ k , '_' ) ) { $ instance -> set ( str_replace_once ( '_' , '' , $ k ) , $ v ) ; unset ( $ this -> request -> data [ $ k ] ) ; } } $ validator = $ this -> FieldInstances -> validator ( 'settings' ) ; $ instance -> validateSettings ( $ this -> request -> data ( ) , $ validator ) ; $ errors = $ validator -> errors ( $ this -> request -> data ( ) , false ) ; if ( empty ( $ errors ) ) { $ instance -> set ( 'settings' , $ this -> request -> data ( ) ) ; $ save = $ this -> FieldInstances -> save ( $ instance ) ; if ( $ save ) { $ this -> Flash -> success ( __d ( 'field' , 'Field information was saved.' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } else { $ this -> Flash -> danger ( __d ( 'field' , 'Your information could not be saved.' ) ) ; } } else { $ this -> Flash -> danger ( __d ( 'field' , 'Field settings could not be saved.' ) ) ; foreach ( $ errors as $ field => $ message ) { $ arrayContext [ 'errors' ] [ $ field ] = $ message ; } } } else { $ arrayContext [ 'defaults' ] = ( array ) $ instance -> settings ; $ this -> request -> data = $ arrayContext [ 'defaults' ] ; } $ this -> title ( __d ( 'field' , 'Configure Field' ) ) ; $ this -> set ( compact ( 'arrayContext' , 'instance' ) ) ; }
docstring: Handles a single field instance configuration parameters.
  
  In FormHelper, all fields prefixed with `_` will be considered as columns
  values of the instance being edited. Any other input element will be
  considered as part of the `settings` column.
  
  For example: `_label`, `_required` and `description` maps to `label`,
  `required` and `description`. And `some_input`, `another_input` maps to
  `settings.some_input`, `settings.another_input`
  
  @param int $id The field instance ID to manage
  @return void
  @throws \Cake\ORM\Exception\RecordNotFoundException When no field instance
  was found
docstring_tokens: Handles a single field instance configuration parameters .