Unchecking the default site settings: Auto-assign items

Hi there,
I’m trying to edit the file SiteSettingsForm.php under src > Form so that the Auto-Assign items isn’t checked by default. I tried the obvious first, changing “true” to “false”, but that didn’t work upon updating and clearing my site’s cache. Then I tried to model off of others in that file ‘value’ => $settings->get(‘o:assign_new_items’), but that didn’t work either. I also tried duplicating this file and putting it under my specific theme’s folder, but that failed as well.

Does anyone have any other suggestions? I was able to uncheck the other settings very easily, but for some reason, this Auto-assign items is tough.

Thanks!

Just chiming in here once more. I still cannot get auto-assign items to default to unchecked. It’s a real issue with us, because many times other managers of sites forget to uncheck this and then un-related items appear on their sites.

In the code, I’ve tried changing to the following, it still didn’t work:

$generalFieldset->add([
‘name’ => ‘o:assign_new_items’,
‘type’ => ‘checkbox’,
‘options’ => [
‘label’ => ‘Auto-assign new items’, // @translate
‘info’ => ‘Select this if you want new items to be automatically assigned to this site. Note that item owners may unassign their items at any time.’, // @translate
],
‘attributes’ => [
‘id’ => ‘assign_new_items’,
‘value’ => false,
],
]);

$generalFieldset->add([
‘name’ => ‘o:assign_new_items’,
‘type’ => ‘checkbox’,
‘options’ => [
‘label’ => ‘Auto-assign new items’, // @translate
‘info’ => ‘Select this if you want new items to be automatically assigned to this site. Note that item owners may unassign their items at any time.’, // @translate
],
‘attributes’ => [
‘id’ => ‘assign_new_items’,
‘value’ => (bool) $settings->get(‘assign_new_items’, false),
],
]);

What version are you using?

I think what’s happening here is that, despite the default set here, assign_new_items is actually set elsewhere… I believe it’s the controller but I’d want to know what version you’re working with to be sure.

Ah, Ok. We’re using Omeka version 3.2.0 . Would it be in the controller in this version?

Actually, I think I just found it, under src > Controller > SiteAdmin > IndexController.php and the following code:

public function addAction()
{
$form = $this->getForm(SiteForm::class);
$themes = $this->themes->getThemes();
if ($this->getRequest()->isPost()) {
$postData = $this->params()->fromPost();
$form->setData($postData);
if ($form->isValid()) {
$formData = $form->getData();
// Set o:assign_new_items to true by default. This is the legacy
// setting from before v3.0 when sites were using the item pool.
$formData[‘o:assign_new_items’] = false;
$formData[‘o:theme’] = $postData[‘o:theme’];
$formData[‘o:is_public’] = $postData[‘o:is_public’];
$response = $this->api($form)->create(‘sites’, $formData);
if ($response) {
$this->messenger()->addSuccess(‘Site successfully created’); // @translate
return $this->redirect()->toUrl($response->getContent()->url());
}
} else {
$this->messenger()->addFormErrors($form);
}
}

I changed it from “true” to “false” and it seems to have worked! Would this be the sole place to change it?

Thanks for helping me find it!

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.