Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Form\KnowledgeArea;use Laminas\Form\Form;use Laminas\Db\Adapter\AdapterInterface;use LeadersLinked\Mapper\KnowledgeAreaCategoryMapper;class KnowledgeAreaCategoryUserDataForm extends Form{/**** @param AdapterInterface $adapter* @param int $company_id*/public function __construct($adapter, $company_id) {parent::__construct();$this->setInputFilter(new KnowledgeAreaCategoryUserDataFilter());$this->add(['name' => 'category_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'category_id',],'options' => [//'disable_inarray_validator' => true,'value_options' => $this->getCategories($adapter, $company_id)]]);}private function getCategories($adapter, $company_id){$items = [];$knowledgeAreaCategoryMapper = KnowledgeAreaCategoryMapper::getInstance($adapter);$records = $knowledgeAreaCategoryMapper->fetchAllByCompanyId($company_id);foreach($records as $record){$items[ $record->uuid ] = $record->name;}return $items;}}