original_string: public function val($field, $options = [])
      {
          $options += [
              'default' => null,
              'schemaDefault' => true
          ];
  
          $val = $this->_request->getData($field);
          if ($val !== null) {
              return $val;
          }
          if ($options['default'] !== null || !$options['schemaDefault']) {
              return $options['default'];
          }
          if (empty($this->_context['defaults']) || !is_array($this->_context['defaults'])) {
              return null;
          }
  
          // Using Hash::check here incase the default value is actually null
          if (Hash::check($this->_context['defaults'], $field)) {
              return Hash::get($this->_context['defaults'], $field);
          }
  
          return Hash::get($this->_context['defaults'], $this->stripNesting($field));
      }
code: public function val($field, $options = [])
      {
          $options += [
              'default' => null,
              'schemaDefault' => true
          ];
  
          $val = $this->_request->getData($field);
          if ($val !== null) {
              return $val;
          }
          if ($options['default'] !== null || !$options['schemaDefault']) {
              return $options['default'];
          }
          if (empty($this->_context['defaults']) || !is_array($this->_context['defaults'])) {
              return null;
          }
  
          // Using Hash::check here incase the default value is actually null
          if (Hash::check($this->_context['defaults'], $field)) {
              return Hash::get($this->_context['defaults'], $field);
          }
  
          return Hash::get($this->_context['defaults'], $this->stripNesting($field));
      }
code_tokens: public function val ( $ field , $ options = [ ] ) { $ options += [ 'default' => null , 'schemaDefault' => true ] ; $ val = $ this -> _request -> getData ( $ field ) ; if ( $ val !== null ) { return $ val ; } if ( $ options [ 'default' ] !== null || ! $ options [ 'schemaDefault' ] ) { return $ options [ 'default' ] ; } if ( empty ( $ this -> _context [ 'defaults' ] ) || ! is_array ( $ this -> _context [ 'defaults' ] ) ) { return null ; } // Using Hash::check here incase the default value is actually null if ( Hash :: check ( $ this -> _context [ 'defaults' ] , $ field ) ) { return Hash :: get ( $ this -> _context [ 'defaults' ] , $ field ) ; } return Hash :: get ( $ this -> _context [ 'defaults' ] , $ this -> stripNesting ( $ field ) ) ; }
docstring: Get the current value for a given field.
  
  This method will coalesce the current request data and the 'defaults'
  array.
  
  @param string $field A dot separated path to the field a value
  is needed for.
  @param array $options Options:
  - `default`: Default value to return if no value found in request
  data or context record.
  - `schemaDefault`: Boolean indicating whether default value from
  context's schema should be used if it's not explicitly provided.
  @return mixed
docstring_tokens: Get the current value for a given field .