Rev 17002 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Form\Job;
use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use LeadersLinked\Mapper\IndustryMapper;
use LeadersLinked\Mapper\CompanySizeMapper;
use LeadersLinked\Mapper\CurrencyMapper;
class JobSalaryForm extends Form
{
/**
*
* @param AdapterInterface $adapter
*/
public function __construct($adapter)
{
parent::__construct();
$this->setInputFilter(new JobSalaryFilter($adapter));
$this->add([
'name' => 'salary_visible',
'type' => \Laminas\Form\Element\Checkbox::class,
'attributes' => [
'id' => 'salary_visible',
],
'options' => [
'use_hidden_element' => false,
'unchecked_value' => \LeadersLinked\Model\Job::SALARY_VISIBLE_NO,
'checked_value'=> \LeadersLinked\Model\Job::SALARY_VISIBLE_YES,
]
]);
$this->add([
'name' => 'salary_min',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'maxlength' => 10,
'id' => 'salary_min',
]
]);
$this->add([
'name' => 'salary_max',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'maxlength' => 10,
'id' => 'salary_max',
]
]);
$this->add([
'name' => 'salary_currency',
'type' => \Laminas\Form\Element\Select::class,
'options' => [
'value_options' => $this->currencyCombo($adapter)
],
'attributes' => [
'id' => 'salary_currency',
]
]);
}
/**
*
* @param AdapterInterface $adapter
* @return array
*/
function currencyCombo($adapter)
{
$mapper = CurrencyMapper::getInstance($adapter);
$records = $mapper->fetchAllActive();
$items = [];
foreach($records as $record)
{
$items[$record->currency] = $record->name;
}
return $items;
}
}