Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Form\PerformanceEvaluation;
use LeadersLinked\Mapper\JobDescriptionMapper;
use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
class PerformanceEvaluationFormForm extends Form
{
public function __construct($adapter, $company_id = 0)
{
parent::__construct();
$this->setInputFilter(new PerformanceEvaluationFormFilter($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' => [
'maxlength' => 1024,
'rows' => 5,
'id' => 'description',
]
]);
$this->add([
'name' => 'job_description_id',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'id' => 'job_description_id',
],
'options' => [
'value_options' => $this->getSelectOptions($adapter, $company_id)
]
]);
/*
$this->add([
'name' => 'content',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'id' => 'content',
]
]);*/
$this->add([
'name' => 'status',
'type' => \Laminas\Form\Element\Checkbox::class,
'attributes' => [
'id' => 'status',
],
'options' => [
'use_hidden_element' => 0,
'unchecked_value' => \LeadersLinked\Model\PerformanceEvaluationForm::STATUS_INACTIVE,
'checked_value'=> \LeadersLinked\Model\PerformanceEvaluationForm::STATUS_ACTIVE,
]
]);
}
/**
*
* @param AdapterInterface $adapter
*/
private function getSelectOptions($adapter, $company_id)
{
$options = [];
$mapper = JobDescriptionMapper::getInstance($adapter);
$records = $mapper->fetchAllActiveByCompanyId($company_id);
foreach($records as $record)
{
$options[$record->uuid] = $record->name;
}
return $options;
}
}