Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions library/Notifications/Web/Form/ContactForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ protected function assemble()
[
'label' => $this->translate('Default Channel'),
'required' => true,
'class' => 'autosubmit',
'disabledOptions' => [''],
'options' => $channelOptions
]
Expand Down Expand Up @@ -402,23 +403,26 @@ private function fetchDbValues(): array
*/
private function addAddressElements(): void
{
$plugins = $this->db->fetchPairs(
AvailableChannelType::on($this->db)
->columns(['type', 'name'])
->assembleSelect()
);
$plugins = AvailableChannelType::on($this->db)
->columns(['type', 'name', 'channel.id'])
->execute();

if (empty($plugins)) {
if (! $plugins->hasResult()) {
return;
}

$selectedChannelId = (int) $this->getValue('contact')['default_channel_id'];

$address = new FieldsetElement('contact_address', ['label' => $this->translate('Addresses')]);
$this->addElement($address);

foreach ($plugins as $type => $label) {
foreach ($plugins as $plugin) {
$type = $plugin->type;

$element = $this->createElement('text', $type, [
'label' => $label,
'validators' => [new StringLengthValidator(['max' => 255])]
'label' => $plugin->name,
'validators' => [new StringLengthValidator(['max' => 255])],
'required' => $plugin->channel->id === $selectedChannelId
]);

if ($type === 'email') {
Expand Down
Loading