Added redirects to client screen after adding or deleting a linked client
This commit is contained in:
parent
d151b1744e
commit
73d9d6490a
@ -117,7 +117,9 @@ table.views-table.views-view-table caption {
|
||||
|
||||
/* remove "details" accordion, see https://drupal.stackexchange.com/questions/294312/why-has-this-details-accordion-appeared-in-this-view */
|
||||
.views-table details {
|
||||
|
||||
display: none;
|
||||
|
||||
}
|
||||
|
||||
form.oc-organisation-relation-form tr:first-child {
|
||||
display: none;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ use Drupal\Core\Entity\EntityTypeInterface;
|
||||
* },
|
||||
* links = {
|
||||
* "canonical" = "/opencase/oc_organisation_relation/{oc_organisation_relation}",
|
||||
* "add-page" = "/opencase//oc_organisation_relation/add",
|
||||
* "add-page" = "/opencase/oc_organisation_relation/add",
|
||||
* "add-form" = "/opencase/oc_organisation_relation/add/{oc_organisation_relation_type}",
|
||||
* "edit-form" = "/opencase/oc_organisation_relation/{oc_organisation_relation}/edit",
|
||||
* "delete-form" = "/opencase/oc_organisation_relation/{oc_organisation_relation}/delete",
|
||||
@ -110,12 +110,6 @@ class OCOrganisationRelation extends ContentEntityBase implements OCOrganisation
|
||||
->setDefaultValue('Link between organisations')
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['status']->setDescription(t('A boolean indicating whether the Organisation Relation is published.'))
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'boolean_checkbox',
|
||||
'weight' => -3,
|
||||
]);
|
||||
|
||||
$fields['created'] = BaseFieldDefinition::create('created')
|
||||
->setLabel(t('Created'))
|
||||
->setDescription(t('The time that the entity was created.'));
|
||||
@ -125,8 +119,7 @@ class OCOrganisationRelation extends ContentEntityBase implements OCOrganisation
|
||||
->setDescription(t('The time that the entity was last edited.'));
|
||||
|
||||
$fields['organisations'] = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Organisations'))
|
||||
->setDescription(t('Linked organisations'))
|
||||
->setLabel(t('Organisation to Link To'))
|
||||
->setSetting('target_type', 'oc_organisation')
|
||||
->setSetting('handler', 'default')
|
||||
->setCardinality(2)
|
||||
@ -144,13 +137,15 @@ class OCOrganisationRelation extends ContentEntityBase implements OCOrganisation
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
])
|
||||
->setDefaultValueCallback('opencase_entities_organisation_relation_callback')
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCOrganisationRelation::defaultValueCallback')
|
||||
->setRequired(TRUE);
|
||||
return $fields;
|
||||
}
|
||||
function defaultValueCallback() {
|
||||
return [\Drupal::request()->query->get('organisation_id')];
|
||||
}
|
||||
}
|
||||
|
||||
function opencase_entities_organisation_relation_callback() {
|
||||
return [\Drupal::request()->query->get('organisation_id')];
|
||||
}
|
||||
|
||||
|
@ -114,3 +114,18 @@ function opencase_entity_field_access($operation, \Drupal\Core\Field\FieldDefini
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter()
|
||||
* Changes what page is redirected to after adding or deleting linked organisation
|
||||
*/
|
||||
function opencase_form_alter(&$form, &$form_state, $form_id) {
|
||||
if (preg_match('/oc_organisation_relation_.*_delete_form/', $form_id) or (preg_match('/oc_organisation_relation_.*_add_form/', $form_id))) {
|
||||
$form['actions']['submit']['#submit'][] = '_opencase_organisation_relation_redirect';
|
||||
// $form['actions']['cancel']['#url'] = $form_state->getFormObject()->getEntity()->toUrl();
|
||||
}
|
||||
}
|
||||
|
||||
function _opencase_organisation_relation_redirect($form, &$form_state) {
|
||||
$organisation_id = \Drupal::request()->query->get('organisation_id');
|
||||
$form_state->setRedirect('entity.oc_organisation.canonical', ['oc_organisation' => $organisation_id]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user