{% import "_includes/forms" as forms %}

{{ forms.textField({
    label: "Host Name"|t('app'),
    id: 'host',
    name: 'host',
    value: adapter.host,
    required: true,
    errors: adapter.getErrors('host')
}) }}

{{ forms.textField({
    label: "Port"|t('app'),
    id: 'port',
    name: 'port',
    value: adapter.port,
    size: 4,
    required: true,
    errors: adapter.getErrors('port')
}) }}

{{ forms.checkboxField({
    label: "Use authentication"|t('app'),
    id: 'useAuthentication',
    name: 'useAuthentication',
    checked: adapter.useAuthentication,
    toggle: 'auth-credentials'
}) }}

<div id="auth-credentials" class="nested-fields{% if not adapter.useAuthentication %} hidden{% endif %}">
    {{ forms.textField({
        label: "Username"|t('app'),
        id: 'username',
        name: 'username',
        value: adapter.username,
        errors: adapter.getErrors('username')
    }) }}

    {{ forms.passwordField({
        label: "Password"|t('app'),
        id: 'password',
        name: 'password',
        value: adapter.password ? adapter.password|encenc,
        errors: adapter.getErrors('password')
    }) }}
</div>

{{ forms.selectField({
    label: "Encryption Method",
    id: 'encryptionMethod',
    name: 'encryptionMethod',
    options: [
        { value: '', label: "None"|t('app') },
        { value: 'ssl', label: "SSL"|t('app') },
        { value: 'tls', label: "TLS"|t('app') }
    ],
    default: 'none',
    value: adapter.encryptionMethod
}) }}

{{ forms.textField({
    label: "Timeout"|t('app'),
    id: 'timeout',
    name: 'timeout',
    value: adapter.timeout,
    size: 2,
    required: true,
    errors: adapter.getErrors('timeout')
}) }}
