public function __construct($formName, $courseList) { parent::__construct(); $this->setName($formName); $this->addHidden('id'); $this->addHidden('recipientsCount')->withData(0); $this->addHidden('enqueuedmsg')->withData(translateFN('Newsletter inoltrata per l\'invio')); $userType = FormControl::create(FormControl::SELECT, 'userType', translateFN('Tipo Utente'))->withData(array(0 => translateFN('Scegli il tipo...'), AMA_TYPE_AUTHOR => translateFN('Autore'), AMA_TYPE_STUDENT => translateFN('Studente'), AMA_TYPE_TUTOR => translateFN('Tutor'), AMA_TYPE_SWITCHER => translateFN('Switcher'), 9999 => translateFN('Tutti')), 0)->setRequired()->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR); $userPlatformStatus = FormControl::create(FormControl::SELECT, 'userPlatformStatus', translateFN('Stato Studente nella Piattaforma'))->withData(array(-1 => translateFN('Scegli lo stato...'), ADA_STATUS_PRESUBSCRIBED => translateFN('Non Confermato'), ADA_STATUS_REGISTERED => translateFN('Confermato')), -1)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR); $userCourseStatus = FormControl::create(FormControl::SELECT, 'userCourseStatus', translateFN('Stato Studente nel corso selezionato'))->withData(array(-1 => translateFN('Scegli lo stato...'), ADA_SERVICE_SUBSCRIPTION_STATUS_UNDEFINED => translateFN('In visita'), ADA_SERVICE_SUBSCRIPTION_STATUS_REQUESTED => translateFN('Preiscritto'), ADA_SERVICE_SUBSCRIPTION_STATUS_ACCEPTED => translateFN('Iscritto'), ADA_SERVICE_SUBSCRIPTION_STATUS_SUSPENDED => translateFN('Rimosso'), ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED => translateFN('Completato')), -1)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR); $this->addFieldset(translateFN('Filtro') . ' ' . translateFN('Utenti'), 'userChoice')->withData(array($userType, $userPlatformStatus, $userCourseStatus)); $courseList[0] = translateFN('Scegli il corso...'); $courseSel = FormControl::create(FormControl::SELECT, 'idCourse', translateFN('Corso'))->withData($courseList, 0)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR); $instanceSel = FormControl::create(FormControl::SELECT, 'idInstance', translateFN('Istanza Corso'))->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR); $this->addFieldset(translateFN('Filtro') . ' ' . translateFN('Corsi'), 'courseChoice')->withData(array($courseSel, $instanceSel)); $this->setSubmitValue(translateFN('Invia Newsletter')); }
/** * @author giorgio 29/mag/2013 * * added extra parameter to constructor to allow editing of student confirmed registration * */ public function __construct($languages = array(), $allowEditProfile = false, $allowEditConfirm = false, $action = null) { parent::__construct(); $this->addHidden('id_utente')->withData(0); /* * @author:Sara 20/05/2014 * Workaround to remove the Google-Chrome autocomplete functionality. */ $j = 'return remove_false_element()'; $this->setOnSubmit($j); $false_username = FormControl::create(FormControl::INPUT_TEXT, 'false_username', ''); $false_password = FormControl::create(FormControl::INPUT_PASSWORD, 'false_password', ''); $false_elements_fieldset = FormControl::create(FormControl::FIELDSET, 'false_elements_fieldset', ''); $false_elements_fieldset->setHidden(); $false_elements_fieldset->withData(array($false_username, $false_password)); $this->addControl($false_elements_fieldset); $this->addPasswordInput('password', translateFN('Password')); //->setValidator(FormValidator::PASSWORD_VALIDATOR); $this->addPasswordInput('passwordcheck', translateFN('Conferma la password')); /** * If the swithcer does not use this form to edit her own * profile, the avatar upload must be disabled */ if ($_SESSION['sess_userObj']->getType() != AMA_TYPE_SWITCHER || !$allowEditConfirm) { $this->addFileInput('avatarfile', translateFN('Seleziona un file immagine per il tuo avatar')); $this->addTextInput('avatar', NULL); } if ($action != null) { $this->setAction($action); } /// $this->addTextInput('telefono', translateFN('Telefono')); $telefono = FormControl::create(FormControl::INPUT_TEXT, 'telefono', translateFN('Telefono')); $cap = FormControl::create(FormControl::INPUT_TEXT, 'cap', translateFN('cap')); $citta = FormControl::create(FormControl::INPUT_TEXT, 'citta', translateFN('Città')); $indirizzo = FormControl::create(FormControl::INPUT_TEXT, 'indirizzo', translateFN('Indirizzo')); $provincia = FormControl::create(FormControl::INPUT_TEXT, 'provincia', translateFN('Provincia')); $countries = countriesList::getCountriesList($_SESSION['sess_user_language']); $nazione = FormControl::create(FormControl::SELECT, 'nazione', translateFN('Nazione')); $nazione->withData($countries); $this->addFieldset(translateFN('Dati residenza'), 'residenza')->withData(array($indirizzo, $cap, $citta, $provincia, $nazione, $telefono)); // $this->addTextInput('indirizzo', translateFN('Indirizzo')); // $this->addTextInput('citta', translateFN('Città')); // $this->addTextInput('provincia', translateFN('Provincia')); /* $countries = countriesList::getCountriesList($_SESSION['sess_user_language']); $this->addSelect( 'nazione', translateFN('Nazione'), $countries, 'IT'); * */ $this->addTextInput('codice_fiscale', translateFN('Cod. Fiscale')); /** * @author giorgio 29/mag/2013 * * added select field to allow editing of user confirmed registration status */ if ($allowEditConfirm) { $this->addSelect('stato', translateFN('Confermato'), array(ADA_STATUS_PRESUBSCRIBED => translateFN('No'), ADA_STATUS_REGISTERED => translateFN('Si')), 0); } //->setValidator(FormValidator::PASSWORD_VALIDATOR); if ($allowEditProfile) { $this->addTextarea('profilo', translateFN('Il tuo profilo utente')); } $layoutsAr = array('' => translateFN('seleziona un layout')); $layoutObj = new UILayout(); $avalaibleLayoutAr = $layoutObj->getAvailableLayouts(); $layouts = array_merge($layoutsAr, $avalaibleLayoutAr); $this->addSelect('layout', translateFN('Layout'), $layouts, 0); if (is_array($languages) && count($languages) > 0) { $languagesAr[0] = translateFN('seleziona una lingua'); $languages = array_replace($languagesAr, $languages); // $languages = array_merge($languagesAr,$languages); $this->addSelect('lingua', translateFN('Lingua'), $languages, 0); } }
/** * Create a new instance of FormControlStatic and return it, use the fluent interface * @param string $name The name of the control * @param FormStorage|string|null $storage A storage location for the data collected by the control * @param array $properties An array of properties that apply to the output HTML * @param array $settings An array of settings that apply to this control object * @return FormControlStatic An instance of the referenced FormControl with the supplied parameters */ public static function create($name, $storage = 'null:null', array $properties = array(), array $settings = array()) { return parent::create($name, $storage, $properties, $settings); }
/** * Adds a new fieldset. * * @param string $id * @param string $label * @return FormControl */ protected final function addFieldset($label, $id = '') { $control = FormControl::create(FormControl::FIELDSET, $id, $label); return $this->addControl($control); }
public function withData($options, $checked = '') { if (is_array($this->_options) && count($this->_options) > 0) { return $this->setSelectedOption($options); } if (is_array($options) && count($options) > 0) { foreach ($options as $value => $text) { $control = FormControl::create(FormControl::OPTION, '', $text); $control->withData($value); if ($value == $checked) { $control->setSelected(); } $this->_options[] = $control; } } return $this; }