[CONTROLLER][UserPanel] Make all fields in settings not required
This commit is contained in:
		@@ -41,6 +41,7 @@ use App\Core\DB\DB;
 | 
			
		||||
use App\Core\Event;
 | 
			
		||||
use App\Core\Form;
 | 
			
		||||
use function App\Core\I18n\_m;
 | 
			
		||||
use App\Core\Log;
 | 
			
		||||
use App\Entity\UserNotificationPrefs;
 | 
			
		||||
use App\Util\Common;
 | 
			
		||||
use App\Util\Exception\AuthenticationException;
 | 
			
		||||
@@ -115,8 +116,8 @@ class UserPanel extends AbstractController
 | 
			
		||||
        $user = Common::user();
 | 
			
		||||
        // TODO Add support missing settings
 | 
			
		||||
        $form = Form::create([
 | 
			
		||||
            ['outgoing_email', TextType::class,        ['label' => _m('Outgoing email'), 'required' => true,  'help' => _m('Change the email we use to contact you')]],
 | 
			
		||||
            ['incoming_email', TextType::class,        ['label' => _m('Incoming email'), 'required' => true,  'help' => _m('Change the email you use to contact us (for posting, for instance)')]],
 | 
			
		||||
            ['outgoing_email', TextType::class,        ['label' => _m('Outgoing email'), 'required' => false,  'help' => _m('Change the email we use to contact you')]],
 | 
			
		||||
            ['incoming_email', TextType::class,        ['label' => _m('Incoming email'), 'required' => false,  'help' => _m('Change the email you use to contact us (for posting, for instance)')]],
 | 
			
		||||
            ['old_password',   TextType::class,        ['label' => _m('Old password'),   'required' => false, 'help' => _m('Enter your old password for verification'), 'attr' => ['placeholder' => '********']]],
 | 
			
		||||
            FormFields::repeated_password(['required' => false]),
 | 
			
		||||
            ['language',       LocaleType::class,      ['label' => _m('Language'),       'required' => false, 'help' => _m('Your preferred language')]],
 | 
			
		||||
@@ -228,8 +229,9 @@ class UserPanel extends AbstractController
 | 
			
		||||
                    // @codeCoverageIgnoreStart
 | 
			
		||||
                } catch (Exception $e) {
 | 
			
		||||
                    // Somehow, the exception doesn't bubble up in phpunit
 | 
			
		||||
                    dd($data, $e);
 | 
			
		||||
                    // dd($data, $e);
 | 
			
		||||
                    // @codeCoverageIgnoreEnd
 | 
			
		||||
                    Log::critical('Exception at ' . $e->getFile() . ':' . $e->getLine() . ': ' . $e->getMessage());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -15,14 +15,14 @@ abstract class FormFields
 | 
			
		||||
{
 | 
			
		||||
    public static function repeated_password(array $options = []): array
 | 
			
		||||
    {
 | 
			
		||||
        return ['password', RepeatedType::class,
 | 
			
		||||
            ['type'             => PasswordType::class,
 | 
			
		||||
        return [
 | 
			
		||||
            'password', RepeatedType::class,
 | 
			
		||||
            [
 | 
			
		||||
                'type'          => PasswordType::class,
 | 
			
		||||
                'first_options' => [
 | 
			
		||||
                    'label'      => _m('Password'),
 | 
			
		||||
                    'label_attr' => ['class' => 'section-form-label'],
 | 
			
		||||
                    'attr'       => ['placeholder' => '********'],
 | 
			
		||||
                    'required'   => $options['required'] ?? true,
 | 
			
		||||
 | 
			
		||||
                    'label'       => _m('Password'),
 | 
			
		||||
                    'label_attr'  => ['class' => 'section-form-label'],
 | 
			
		||||
                    'attr'        => ['placeholder' => '********'],
 | 
			
		||||
                    'constraints' => [
 | 
			
		||||
                        new NotBlank(['message' => _m('Please enter a password')]),
 | 
			
		||||
                        new Length(['min' => Common::config('password', 'min_length'), 'minMessage' => _m(['Your password should be at least # characters'], ['count' => Common::config('password', 'min_length')]),
 | 
			
		||||
@@ -37,6 +37,7 @@ abstract class FormFields
 | 
			
		||||
                    'help'       => _m('Confirm your password.'),
 | 
			
		||||
                ],
 | 
			
		||||
                'mapped'          => false,
 | 
			
		||||
                'required'        => $options['required'] ?? true,
 | 
			
		||||
                'invalid_message' => _m('The password fields must match'),
 | 
			
		||||
            ],
 | 
			
		||||
        ];
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user