AutorÃa | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Form\KnowledgeArea;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;use Laminas\Db\Adapter\Adapter;use LeadersLinked\Mapper\KnowledgeAreaCategoryMapper;class KnowledgeAreaEditForm extends Form{/**** @param AdapterInterface $adapter* @param int[] $category_with_edition_ids*/public function __construct($adapter, $category_with_edition_ids){parent::__construct();$this->setInputFilter(new KnowledgeAreaEditFilter());$this->add(['name' => 'category_id','type' => \Laminas\Form\Element\Select::class,'options' => ['value_options' => $this->getCategories($adapter, $category_with_edition_ids)],'attributes' => ['id' => 'category_id',]]);$this->add(['name' => 'title','type' => \Laminas\Form\Element\Textarea::class,'attributes' => ['id' => 'title','maxlength' => 120]]);$this->add(['name' => 'description','type' => \Laminas\Form\Element\Textarea::class,'attributes' => ['id' => 'description',]]);$this->add(['name' => 'image','type' => \Laminas\Form\Element\File::class,'attributes' => ['id' => 'image',]]);$this->add(['name' => 'attachment','type' => \Laminas\Form\Element\File::class,'attributes' => ['id' => 'attachment',]]);$this->add(['name' => 'link','type' => \Laminas\Form\Element\Url::class,'attributes' => ['id' => 'link',]]);}/**** @param AdapterInterface $adapter* @param int[] $category_with_edition_ids* @return array*/private function getCategories($adapter, $category_with_edition_ids){$options = [];$knowledgeAreaCategoryMapper = KnowledgeAreaCategoryMapper::getInstance($adapter);$records = $knowledgeAreaCategoryMapper->fetchAllByIds($category_with_edition_ids);foreach($records as $record){$options[ $record->uuid ] = $record->name;}return $options;}}