original_string: protected function getFormFieldGeneratedRule(ModelFormFieldDataInterface $field, $forCreate, array &$rules)
      {
          $this->generatedRulesMap[ $field->key() ] = [];
  
          if ( ! $this->isFormFieldRelevant($field, $forCreate)) {
              return;
          }
  
          // The rules returned by a strategy (specific), and those provided by the
          // field type (attribute/relation), must first be combined --
          // and in preparation for that be cast as uniform arrays of ValidationRuleData instances.
  
          $fieldRules = $this->getAndMergeFormFieldRulesForStrategyAndBasedOnModelInformation($field, $forCreate);
  
          // If the field is translated, mark the rules for it in preparation for further decoration
          if ($field->translated()) {
              array_map(function (ValidationRuleDataInterface $rule) {
                  $rule->setIsTranslated();
              }, $fieldRules);
          }
  
          // The keys in the strategy or model information might have placeholders
          // in its rules, to allow referring to other 'relative' validation keys
          // for the field such as in required_with... rules.
          // These placeholders need to be replaced.
          $fieldRules = $this->replaceFieldKeyPlaceholderInValidationRules($field, $fieldRules);
  
  
          // At this point we have a normalized array of data objects,
          // which has dot-notation keys (for array-nested rules) that is offset
          // for the field (so it leaves out the field key itself).
          // Rules for the field key itself will thus have empty/null keys.
  
          // The rules will also have been collapsed to one per key.
  
          foreach ($fieldRules as $rule) {
  
              if (empty($rule->key())) {
                  $rule->setKey($field->key());
                  $rules[ $field->key() ] = $rule;
                  $this->generatedRulesMap[ $field->key() ][] = $field->key();
                  continue;
              }
  
              $rule->prefixKey($field->key());
  
              $rules[ $rule->key() ] = $rule;
              $this->generatedRulesMap[ $field->key() ][] = $rule->key();
          }
      }
code: protected function getFormFieldGeneratedRule(ModelFormFieldDataInterface $field, $forCreate, array &$rules)
      {
          $this->generatedRulesMap[ $field->key() ] = [];
  
          if ( ! $this->isFormFieldRelevant($field, $forCreate)) {
              return;
          }
  
          // The rules returned by a strategy (specific), and those provided by the
          // field type (attribute/relation), must first be combined --
          // and in preparation for that be cast as uniform arrays of ValidationRuleData instances.
  
          $fieldRules = $this->getAndMergeFormFieldRulesForStrategyAndBasedOnModelInformation($field, $forCreate);
  
          // If the field is translated, mark the rules for it in preparation for further decoration
          if ($field->translated()) {
              array_map(function (ValidationRuleDataInterface $rule) {
                  $rule->setIsTranslated();
              }, $fieldRules);
          }
  
          // The keys in the strategy or model information might have placeholders
          // in its rules, to allow referring to other 'relative' validation keys
          // for the field such as in required_with... rules.
          // These placeholders need to be replaced.
          $fieldRules = $this->replaceFieldKeyPlaceholderInValidationRules($field, $fieldRules);
  
  
          // At this point we have a normalized array of data objects,
          // which has dot-notation keys (for array-nested rules) that is offset
          // for the field (so it leaves out the field key itself).
          // Rules for the field key itself will thus have empty/null keys.
  
          // The rules will also have been collapsed to one per key.
  
          foreach ($fieldRules as $rule) {
  
              if (empty($rule->key())) {
                  $rule->setKey($field->key());
                  $rules[ $field->key() ] = $rule;
                  $this->generatedRulesMap[ $field->key() ][] = $field->key();
                  continue;
              }
  
              $rule->prefixKey($field->key());
  
              $rules[ $rule->key() ] = $rule;
              $this->generatedRulesMap[ $field->key() ][] = $rule->key();
          }
      }
code_tokens: protected function getFormFieldGeneratedRule ( ModelFormFieldDataInterface $ field , $ forCreate , array & $ rules ) { $ this -> generatedRulesMap [ $ field -> key ( ) ] = [ ] ; if ( ! $ this -> isFormFieldRelevant ( $ field , $ forCreate ) ) { return ; } // The rules returned by a strategy (specific), and those provided by the // field type (attribute/relation), must first be combined -- // and in preparation for that be cast as uniform arrays of ValidationRuleData instances. $ fieldRules = $ this -> getAndMergeFormFieldRulesForStrategyAndBasedOnModelInformation ( $ field , $ forCreate ) ; // If the field is translated, mark the rules for it in preparation for further decoration if ( $ field -> translated ( ) ) { array_map ( function ( ValidationRuleDataInterface $ rule ) { $ rule -> setIsTranslated ( ) ; } , $ fieldRules ) ; } // The keys in the strategy or model information might have placeholders // in its rules, to allow referring to other 'relative' validation keys // for the field such as in required_with... rules. // These placeholders need to be replaced. $ fieldRules = $ this -> replaceFieldKeyPlaceholderInValidationRules ( $ field , $ fieldRules ) ; // At this point we have a normalized array of data objects, // which has dot-notation keys (for array-nested rules) that is offset // for the field (so it leaves out the field key itself). // Rules for the field key itself will thus have empty/null keys. // The rules will also have been collapsed to one per key. foreach ( $ fieldRules as $ rule ) { if ( empty ( $ rule -> key ( ) ) ) { $ rule -> setKey ( $ field -> key ( ) ) ; $ rules [ $ field -> key ( ) ] = $ rule ; $ this -> generatedRulesMap [ $ field -> key ( ) ] [ ] = $ field -> key ( ) ; continue ; } $ rule -> prefixKey ( $ field -> key ( ) ) ; $ rules [ $ rule -> key ( ) ] = $ rule ; $ this -> generatedRulesMap [ $ field -> key ( ) ] [ ] = $ rule -> key ( ) ; } }
docstring: Updates collected rules array with rules based on form field data.
  
  @param ModelFormFieldDataInterface|ModelFormFieldData $field
  @param bool                                           $forCreate
  @param array                                          $rules     by reference
docstring_tokens: Updates collected rules array with rules based on form field data .