You are here

protected function FieldValidationRuleAddForm::prepareFieldValidationRule in Field Validation 8

Converts a field_validation_rule ID into an object.

Parameters

string $field_validation_rule: The field_validation_rule ID.

Return value

\Drupal\field_validation\FieldValidationRuleInterface The field_validation_rule object.

Overrides FieldValidationRuleFormBase::prepareFieldValidationRule

File

src/Form/FieldValidationRuleAddForm.php, line 56

Class

FieldValidationRuleAddForm
Provides an add form for field validation rule.

Namespace

Drupal\field_validation\Form

Code

protected function prepareFieldValidationRule($field_validation_rule) {
  $field_validation_rule = $this->fieldValidationRuleManager
    ->createInstance($field_validation_rule);

  // Set the initial weight so this field_validation_rule comes last.
  $field_validation_rule
    ->setWeight(count($this->fieldValidationRuleSet
    ->getFieldValidationRules()));
  return $field_validation_rule;
}