Skip to content
Snippets Groups Projects

Issue #3458783: Ensure the month limit is consistent with the field definition settings

Open codebymikey requested to merge issue/smart_date-3458783:3458783-ensure-the-month into 4.1.x
1 file
+ 7
2
Compare changes
  • Side-by-side
  • Inline
@@ -4,6 +4,7 @@ namespace Drupal\smart_date_recur;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\smart_date\SmartDateTrait;
use Drupal\smart_date_recur\Entity\SmartDateRule;
/**
* Provides friendly methods for smart date range.
@@ -224,8 +225,12 @@ trait SmartDateRecurTrait {
* Retrieve the months_limit value from the field definition.
*/
public function getMonthsLimit($field_def) {
$month_limit = $this->getThirdPartyFallback($field_def, 'month_limit', 12);
return $month_limit;
if (($field_def instanceof SmartDateRule) && $parent_entity = $field_def->getParentEntity()) {
/** @var \Drupal\Core\Entity\FieldableEntityInterface $parent_entity */
$field_name = $field_def->get('field_name')->value;
$field_def = $parent_entity->getFieldDefinition($field_name);
}
return $this->getThirdPartyFallback($field_def, 'month_limit', 12);
}
/**
Loading