Rev 16325 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Form\MyCoach;use Laminas\Form\Form;use Laminas\Db\Adapter\AdapterInterface;use Laminas\Log\LoggerInterface;use LeadersLinked\Model\Topic;use Laminas\Form\Element;use LeadersLinked\Mapper\UserMapper;class MyCoachCategoryForm extends Form{/**** @param AdapterInterface $adapter* @param int $company_id* @param int $allowPrivacyPublic*/public function __construct($adapter, $company_id, $allowPrivacyPublic) {parent::__construct();$this->setInputFilter(new MyCoachCategoryFilter($adapter));$this->add(['name' => 'name','type' => \Laminas\Form\Element\Text::class,'attributes' => ['maxlength' => 128,'id' => 'name',]]);$this->add(['name' => 'description','type' => \Laminas\Form\Element\Textarea::class,'attributes' => ['id' => 'description',]]);$this->add(['name' => 'status','type' => \Laminas\Form\Element\Checkbox::class,'attributes' => ['id' => 'status',],'options' => ['use_hidden_element' => 0,'unchecked_value' => \LeadersLinked\Model\MyCoachCategory::STATUS_INACTIVE,'checked_value'=> \LeadersLinked\Model\MyCoachCategory::STATUS_ACTIVE]]);$options = [];if($allowPrivacyPublic) {$options = [\LeadersLinked\Model\MyCoachCategory::PRIVATY_PUBLIC => 'LABEL_PUBLIC',\LeadersLinked\Model\MyCoachCategory::PRIVACY_COMPANY => 'LABEL_COMPANY',];} else {$options = [\LeadersLinked\Model\MyCoachCategory::PRIVACY_COMPANY => 'LABEL_COMPANY',];}$this->add(['name' => 'privacy','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'privacy',],'options' => [//'disable_inarray_validator' => true,'value_options' => $options]]);$this->add(['name' => 'editors','type' => \Laminas\Form\Element\Select::class,'attributes' => ['multiple' => true,'id' => 'editors',],'options' => ['disable_inarray_validator' => true,'value_options' => $this->editorOptions($adapter, $company_id),]]);}private function editorOptions($adapter, $company_id){$options = [];$userMapper = UserMapper::getInstance($adapter);$records = $userMapper->fetchAllByCompanyId($company_id);foreach($records as $record){$options[ $record->uuid ] = trim($record->first_name . ' ' . $record->last_name . '(' . $record->email . ')');}return $options;}}