Rev 17214 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Form\Microlearning;use Laminas\Form\Form;use Laminas\Form\Element\Select;use Laminas\Form\Element\Textarea;use Laminas\Form\Element\Text;use Laminas\Form\Element\Hidden;use LeadersLinked\Model\Company;use LeadersLinked\Model\MicrolearningTopic;use LeadersLinked\Mapper\MicrolearningCapsuleMapper;class TopicAddForm extends Form{public function __construct($adapter, $company_id, $internal = Company::INTERNAL_NO){parent::__construct();$this->setInputFilter(new TopicAddFilter($adapter));$this->add(['name' => 'name','type' => Textarea::class,'attributes' => ['id' => 'name',]]);$this->add(['name' => 'description','type' => Textarea::class,'attributes' => ['id' => 'description',]]);$this->add(['name' => 'order','type' => Text::class,'attributes' => ['id' => 'order',],]);$this->add(['name' => 'image','type' => Hidden::class,'attributes' => ['id' => 'image',]]);$this->add(['name' => 'marketplace','type' => Hidden::class,'attributes' => ['id' => 'marketplace',]]);$this->add(['name' => 'status','type' => Select::class,'options' => ['empty_option' => 'LABEL_STATUS','value_options' => [MicrolearningTopic::STATUS_ACTIVE => 'LABEL_ACTIVE',MicrolearningTopic::STATUS_INACTIVE => 'LABEL_INACTIVE',],],'attributes' => ['id' => 'status',]]);if($internal == Company::INTERNAL_YES) {$value_options = [MicrolearningTopic::PRIVACY_PRIVATE => 'LABEL_PRIVATE',MicrolearningTopic::PRIVACY_PUBLIC => 'LABEL_PUBLIC',];} else {$value_options = [MicrolearningTopic::PRIVACY_PRIVATE => 'LABEL_PRIVATE',];}$this->add(['name' => 'privacy','type' => Select::class,'options' => ['empty_option' => 'LABEL_PRIVACY','value_options' => $value_options,],'attributes' => ['id' => 'privacy',]]);if($internal == Company::INTERNAL_YES) {$value_options = [MicrolearningTopic::TYPE_FREE => 'LABEL_FREE',MicrolearningTopic::TYPE_SELLING => 'LABEL_SELLING',MicrolearningTopic::TYPE_PRIVATE => 'LABEL_PRIVATE',];} else {$value_options = [MicrolearningTopic::TYPE_PRIVATE => 'LABEL_PRIVATE',];}$this->add(['name' => 'type','type' => Select::class,'options' => ['empty_option' => 'LABEL_TYPE','value_options' => $value_options,],'attributes' => ['id' => 'type',]]);$this->add(['name' => 'cost','type' => Text::class,'attributes' => ['id' => 'cost',],]);$this->add(['name' => 'capsule_uuid','type' => Select::class,'attributes' => ['multiple' => 'yes','id' => 'capsule_uuid',],'options' => ['disable_inarray_validator' => true,'value_options' => $this->getSelectOptions($adapter, $company_id)]]);}private function getSelectOptions($adapter, $company_id){$options = [];$mapper = MicrolearningCapsuleMapper::getInstance($adapter);$records = $mapper->fetchAllByCompanyId($company_id);foreach($records as $record){$options[$record->uuid] = $record->name;}return $options;}}