TheMainStreamer
Member
Hello, that's a repost because @S Thomas said that my first post is simply to long to understand my problem.
Since the last week I'm trying to add a new display location for some input fields in the account settings location.
I want to add for example a new location for a first name. Everything works fine. I was able to add the new location into the custom user field section and added it to the database. My new field also gets displayed on my website.
The problem which I have is if I press the "save" button after I've changed the first name (In my gif example "Test Name") in the account settings it doesn't get saved. It must be because I've forget to add a save process or something like that for my new display location.
A small gif which shows my problem and a picture which shows the new display locations:
To get it displayed into the admin cp I've also created a new path in my add-on (XF/Repository)
To get my new display location displayed into my settings template I've added this code into my account_details file:
Hopefully someone can help me with that.
Justus
Since the last week I'm trying to add a new display location for some input fields in the account settings location.
I want to add for example a new location for a first name. Everything works fine. I was able to add the new location into the custom user field section and added it to the database. My new field also gets displayed on my website.
The problem which I have is if I press the "save" button after I've changed the first name (In my gif example "Test Name") in the account settings it doesn't get saved. It must be because I've forget to add a save process or something like that for my new display location.
A small gif which shows my problem and a picture which shows the new display locations:
PHP:
<?php
namespace DisplayLocation;
use XF\Db\Schema\Alter;
use XF\Db\Schema\Create;
use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;
class Setup extends AbstractSetup
{
use StepRunnerInstallTrait;
use StepRunnerUpgradeTrait;
use StepRunnerUninstallTrait;
public function installStep1()
{
$this->schemaManager()->alterTable('xf_user_field', function(Alter $table)
{
$table->changeColumn('display_group')->addValues('extra_space_settings');
});
}
public function installStep2()
{
$this->schemaManager()->alterTable('xf_user_field', function(Alter $table)
{
$table->changeColumn('display_group')->addValues('left_row_settings');
});
}
public function installStep3()
{
$this->schemaManager()->alterTable('xf_user_field', function(Alter $table)
{
$table->changeColumn('display_group')->addValues('right_row_settings');
});
}
public function uninstallStep1()
{
$db = \XF::db();
$db->query("UPDATE `xf_user_field` SET `display_group` = 'personal' WHERE `display_group` = 'extra_space_settings'");
$this->schemaManager()->alterTable('xf_user_field', function(Alter $table)
{
$table->changeColumn('display_group')->removeValues('extra_space_settings');
});
}
public function uninstallStep2()
{
$db = \XF::db();
$db->query("UPDATE `xf_user_field` SET `display_group` = 'personal' WHERE `display_group` = 'left_row_settings'");
$this->schemaManager()->alterTable('xf_user_field', function(Alter $table)
{
$table->changeColumn('display_group')->removeValues('left_row_settings');
});
}
public function uninstallStep3()
{
$db = \XF::db();
$db->query("UPDATE `xf_user_field` SET `display_group` = 'personal' WHERE `display_group` = 'right_row_settings'");
$this->schemaManager()->alterTable('xf_user_field', function(Alter $table)
{
$table->changeColumn('display_group')->removeValues('right_row_settings');
});
}
}
PHP:
<?php
namespace DisplayLocation;
use XF\Mvc\Entity\Entity;
class Listener
{
public static function userFieldEntityStructure(\XF\Mvc\Entity\Manager $em, \XF\Mvc\Entity\Structure &$structure)
{
$structure->columns['display_group']['allowedValues'][] = 'extra_space_settings';
//print_r($structure);
//die();
$structure->columns['display_group']['allowedValues'][] = 'left_row_settings';
//print_r($structure);
//die();
$structure->columns['display_group']['allowedValues'][] = 'right_row_settings';
//print_r($structure);
//die();
}
}
PHP:
<?php
namespace DisplayLocation\XF\Repository;
class UserField extends \XF\Repository\UserField
{
public function getDisplayGroups()
{
$groups = parent::getDisplayGroups();
$groups['extra_space_settings'] = \XF::phrase('Extra Space');
$groups['left_row_settings'] = \XF::phrase('Left Row');
$groups['right_row_settings'] = \XF::phrase('Right Row');
return $groups;
}
}
<xf:macro template="custom_fields_macros" name="custom_fields_edit" arg-type="users" arg-group="extra_space_settings" arg-set="{$xf.visitor.Profile.custom_fields}" />
Hopefully someone can help me with that.
Justus
Last edited: