Rev 16248 | 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;use LeadersLinked\Model\KnowledgeAreaCategory;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){switch($record->privacy){case KnowledgeAreaCategory::PRIVACY_COMPANY :$privacy = 'LABEL_COMPANY';break;case KnowledgeAreaCategory::PRIVACY_PUBLIC :$privacy = 'LABEL_PUBLIC';break;default :$privacy = 'LABEL_UNKNOW';break;}$items[ $record->uuid ] = $record->name . ' (' . $privacy . ')';}return $items;}}