Rev 307 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Form\Habit;
use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Log\LoggerInterface;
use LeadersLinked\Mapper\CompanySizeMapper;
use LeadersLinked\Mapper\IndustryMapper;
use LeadersLinked\Model\Feed;
class HabitGoalForm extends Form
{
/**
*
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
* @param int $user_id
*/
public function __construct($adapter, $user_id)
{
parent::__construct();
$this->setInputFilter(new HabitGoalFilter($adapter, $user_id));
$this->add([
'name' => 'name',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'id' => 'name',
'maxlength' => 100
]
]);
$this->add([
'name' => 'description',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'id' => 'description',
'maxlength' => 512
]
]);
$this->add([
'name' => 'value',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'id' => 'value',
'maxlength' => 5
]
]);
$this->add([
'name' => 'start_date',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'id' => 'start_date',
'maxlength' => 20
]
]);
$this->add([
'name' => 'end_date',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'id' => 'end_date',
'maxlength' => 20
]
]);
$this->add([
'name' => 'skill_id',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'multiple' => 'yes',
'id' => 'skill_id',
],
'options' => [
'disable_inarray_validator' => true,
'value_options' => $this->getSelectOptions($adapter, $user_id)
]
]);
}
private function getSelectOptions($adapter, $user_id)
{
$items = [];
$habitSkillMapper = \LeadersLinked\Mapper\HabitSkillMapper::getInstance($adapter);
$records = $habitSkillMapper->fetchAllByUserId($user_id);
foreach($records as $record)
{
$items[ $record->uuid ] = $record->name;
}
return $items;
}
}