AutorÃa | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Form\DiscoveryContact;
use Laminas\Form\Form;
use Laminas\Db\Adapter\Adapter;
use LeadersLinked\Mapper\DiscoveryContactBlackListReasonMapper;
class BlackListAddForm extends Form
{
/**
*
* @param Adapter $adapter
* @param int $company_id
*/
public function __construct($adapter, $company_id)
{
parent::__construct();
$this->setInputFilter(new BlackListAddFilter($adapter, $company_id));
$this->add([
'name' => 'email',
'type' => \Laminas\Form\Element\Select::class,
'options' => [
'empty_option' => 'LABEL_SELECT',
'value_options' => [],
'disable_inarray_validator' => true,
],
'attributes' => [
'id' => 'email',
]
]);
$this->add([
'name' => 'notes',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'id' => 'notes',
]
]);
$this->add([
'name' => 'blacklist_reason_id',
'type' => \Laminas\Form\Element\Select::class,
'options' => [
'empty_option' => 'LABEL_SELECT',
'value_options' => $this->optionsReasons($adapter, $company_id),
],
'attributes' => [
'id' => 'blacklist_reason_id',
]
]);
}
private function optionsReasons($adapter, $company_id)
{
$items = [];
$discoveryContactBlackListReasonMapper = DiscoveryContactBlackListReasonMapper::getInstance($adapter);
$records = $discoveryContactBlackListReasonMapper->fetchAllActiveByCompanyId($company_id);
foreach($records as $record)
{
$items[ $record->uuid ] = $record->name;
}
return $items;
}
}