original_string: public function allowEmptyFor($field, $flags, $when = true, $message = null)
      {
          $this->field($field)->allowEmpty($when);
          if ($message) {
              $this->_allowEmptyMessages[$field] = $message;
          }
          if ($flags !== null) {
              $this->_allowEmptyFlags[$field] = $flags;
          }
  
          return $this;
      }
code: public function allowEmptyFor($field, $flags, $when = true, $message = null)
      {
          $this->field($field)->allowEmpty($when);
          if ($message) {
              $this->_allowEmptyMessages[$field] = $message;
          }
          if ($flags !== null) {
              $this->_allowEmptyFlags[$field] = $flags;
          }
  
          return $this;
      }
code_tokens: public function allowEmptyFor ( $ field , $ flags , $ when = true , $ message = null ) { $ this -> field ( $ field ) -> allowEmpty ( $ when ) ; if ( $ message ) { $ this -> _allowEmptyMessages [ $ field ] = $ message ; } if ( $ flags !== null ) { $ this -> _allowEmptyFlags [ $ field ] = $ flags ; } return $ this ; }
docstring: Indicate that a field can be empty.
  
  Using an array will let you provide the following keys:
  
  - `flags` individual flags for field
  - `when` individual when condition for field
  - `message` individual message for field
  
  You can also set flags, when and message for all passed fields, the individual
  setting takes precedence over group settings.
  
  ### Example:
  
  ```
  // Email can be empty
  $validator->allowEmptyFor('email', Validator::EMPTY_STRING);
  
  // Email can be empty on create
  $validator->allowEmptyFor('email', Validator::EMPTY_STRING, 'create');
  
  // Email can be empty on update
  $validator->allowEmptyFor('email', Validator::EMPTY_STRING, 'update');
  ```
  
  It is possible to conditionally allow emptiness on a field by passing a callback
  as a second argument. The callback will receive the validation context array as
  argument:
  
  ```
  $validator->allowEmpty('email', Validator::EMPTY_STRING, function ($context) {
  return !$context['newRecord'] || $context['data']['role'] === 'admin';
  });
  ```
  
  If you want to allow other kind of empty data on a field, you need to pass other
  flags:
  
  ```
  $validator->allowEmptyFor('photo', Validator::EMPTY_FILE);
  $validator->allowEmptyFor('published', Validator::EMPTY_STRING | Validator::EMPTY_DATE | Validator::EMPTY_TIME);
  $validator->allowEmptyFor('items', Validator::EMPTY_STRING | Validator::EMPTY_ARRAY);
  ```
  
  You can also use convenience wrappers of this method. The following calls are the
  same as above:
  
  ```
  $validator->allowEmptyFile('photo');
  $validator->allowEmptyDateTime('published');
  $validator->allowEmptyArray('items');
  ```
  
  @param string $field The name of the field.
  @param int|null $flags A bitmask of EMPTY_* flags which specify what is empty
  @param bool|string|callable $when Indicates when the field is allowed to be empty
  Valid values are true, false, 'create', 'update'. If a callable is passed then
  the field will allowed to be empty only when the callback returns true.
  @param string|null $message The message to show if the field is not
  @since 3.7.0
  @return $this
docstring_tokens: Indicate that a field can be empty .