original_string: protected function _optionsOptions($fieldName, $options)
      {
          if (isset($options['options'])) {
              return $options;
          }
  
          $pluralize = true;
          if (substr($fieldName, -5) === '._ids') {
              $fieldName = substr($fieldName, 0, -5);
              $pluralize = false;
          } elseif (substr($fieldName, -3) === '_id') {
              $fieldName = substr($fieldName, 0, -3);
          }
          $fieldName = array_slice(explode('.', $fieldName), -1)[0];
  
          $varName = Inflector::variable(
              $pluralize ? Inflector::pluralize($fieldName) : $fieldName
          );
          $varOptions = $this->_View->get($varName);
          if (!is_array($varOptions) && !($varOptions instanceof Traversable)) {
              return $options;
          }
          if ($options['type'] !== 'radio') {
              $options['type'] = 'select';
          }
          $options['options'] = $varOptions;
  
          return $options;
      }
code: protected function _optionsOptions($fieldName, $options)
      {
          if (isset($options['options'])) {
              return $options;
          }
  
          $pluralize = true;
          if (substr($fieldName, -5) === '._ids') {
              $fieldName = substr($fieldName, 0, -5);
              $pluralize = false;
          } elseif (substr($fieldName, -3) === '_id') {
              $fieldName = substr($fieldName, 0, -3);
          }
          $fieldName = array_slice(explode('.', $fieldName), -1)[0];
  
          $varName = Inflector::variable(
              $pluralize ? Inflector::pluralize($fieldName) : $fieldName
          );
          $varOptions = $this->_View->get($varName);
          if (!is_array($varOptions) && !($varOptions instanceof Traversable)) {
              return $options;
          }
          if ($options['type'] !== 'radio') {
              $options['type'] = 'select';
          }
          $options['options'] = $varOptions;
  
          return $options;
      }
code_tokens: protected function _optionsOptions ( $ fieldName , $ options ) { if ( isset ( $ options [ 'options' ] ) ) { return $ options ; } $ pluralize = true ; if ( substr ( $ fieldName , - 5 ) === '._ids' ) { $ fieldName = substr ( $ fieldName , 0 , - 5 ) ; $ pluralize = false ; } elseif ( substr ( $ fieldName , - 3 ) === '_id' ) { $ fieldName = substr ( $ fieldName , 0 , - 3 ) ; } $ fieldName = array_slice ( explode ( '.' , $ fieldName ) , - 1 ) [ 0 ] ; $ varName = Inflector :: variable ( $ pluralize ? Inflector :: pluralize ( $ fieldName ) : $ fieldName ) ; $ varOptions = $ this -> _View -> get ( $ varName ) ; if ( ! is_array ( $ varOptions ) && ! ( $ varOptions instanceof Traversable ) ) { return $ options ; } if ( $ options [ 'type' ] !== 'radio' ) { $ options [ 'type' ] = 'select' ; } $ options [ 'options' ] = $ varOptions ; return $ options ; }
docstring: Selects the variable containing the options for a select field if present,
  and sets the value to the 'options' key in the options array.
  
  @param string $fieldName The name of the field to find options for.
  @param array $options Options list.
  @return array
docstring_tokens: Selects the variable containing the options for a select field if present and sets the value to the options key in the options array .