Commit 8cee3c50 authored by RoSk0's avatar RoSk0

Added ability to prepopulate relation form.

parent 0ec4d706
......@@ -10,6 +10,32 @@ use Drupal\Core\Form\FormStateInterface;
*/
class RelationForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
$individual_id = $this->getRequest()->query->get('individual_id');
$user_id = $this->getRequest()->query->get('user_id');
if ($individual_id || $user_id) {
$relation = $this->getEntity();
$relation->setIndividualId($individual_id);
$relation->setUserId($user_id);
$this->setEntity($relation);
}
$form = parent::form($form, $form_state);
if ($individual_id) {
$form['individual_id']['widget']['#disabled'] = TRUE;
}
if ($user_id) {
$form['user_id']['widget']['#disabled'] = TRUE;
}
return $form;
}
/**
* {@inheritdoc}
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment