public static function BackgroundImageFormTrait::initWithFormState in Background Image 2.0.x
Same name and namespace in other branches
- 8 src/BackgroundImageFormTrait.php \Drupal\background_image\BackgroundImageFormTrait::initWithFormState()
- 2.x src/BackgroundImageFormTrait.php \Drupal\background_image\BackgroundImageFormTrait::initWithFormState()
Retrieves existing instance or creates new one from form state.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current form state object.
Return value
self
File
- src/
BackgroundImageFormTrait.php, line 454
Class
- BackgroundImageFormTrait
- Trait BackgroundImageFormTrait.
Namespace
Drupal\background_imageCode
public static function initWithFormState(FormStateInterface $form_state) {
/** @var self $self */
$self = $form_state
->get(self::class);
if (!$self) {
$self = new self();
$form_state
->set(self::class, $self);
}
return $self
->setForm($form_state
->getCompleteForm())
->setFormState($form_state);
}