Rev 4455 | AutorÃa | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Form;
use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Log\LoggerInterface;
use LeadersLinked\Mapper\CompanySizeMapper;
use LeadersLinked\Mapper\SurveyFormMapper;
use LeadersLinked\Model\SurveyForm;
class SurveyFormForm extends Form
{
/**
*
* @param AdapterInterface $adapter
* @param int $company_id
*/
public function __construct($adapter, $company_id)
{
parent::__construct();
$this->setInputFilter(new SurveyFormFilter($adapter));
$this->add([
'name' => 'name',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'maxlength' => 128,
'id' => 'name',
]
]);
$this->add([
'name' => 'description',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'id' => 'description',
],
]);
$this->add([
'name' => 'text',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'id' => 'text',
],
]);
$this->add([
'name' => 'status',
'type' => \Laminas\Form\Element\Select::class,
'options' => [
'empty_option' => 'LABEL_STATUS',
'value_options' => [
SurveyForm::STATUS_ACTIVE => 'LABEL_ACTIVE',
SurveyForm::STATUS_INACTIVE => 'LABEL_INACTIVE',
],
],
'attributes' => [
'id' => 'status',
]
]);
$this->add([
'name' => 'content',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'id' => 'content',
]
]);
}
/**
*
* @param AdapterInterface $adapter
*/
private function getSelectFormOptions($adapter, $company_id)
{
$options = [];
$mapper = SurveyFormMapper::getInstance($adapter);
$records = $mapper->fetchAllByCompanyId($company_id);
foreach($records as $record)
{
$options[$record->uuid] = $record->name;
}
return $options;
}
}