當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ilNonEditableValueGUI::setRequired方法代碼示例

本文整理匯總了PHP中ilNonEditableValueGUI::setRequired方法的典型用法代碼示例。如果您正苦於以下問題:PHP ilNonEditableValueGUI::setRequired方法的具體用法?PHP ilNonEditableValueGUI::setRequired怎麽用?PHP ilNonEditableValueGUI::setRequired使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ilNonEditableValueGUI的用法示例。


在下文中一共展示了ilNonEditableValueGUI::setRequired方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: showCustomFields

 /**
  * Show course defined fields
  *
  * @access protected
  */
 protected function showCustomFields()
 {
     global $ilUser;
     include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php';
     include_once 'Modules/Course/classes/Export/class.ilCourseUserData.php';
     if (!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->container->getId()))) {
         return true;
     }
     $cdf = new ilNonEditableValueGUI($this->lng->txt('ps_crs_user_fields'));
     $cdf->setValue($this->lng->txt($this->type . '_ps_cdf_info'));
     $cdf->setRequired(true);
     foreach ($cdf_fields as $field_obj) {
         $course_user_data = new ilCourseUserData($ilUser->getId(), $field_obj->getId());
         switch ($field_obj->getType()) {
             case IL_CDF_TYPE_SELECT:
                 $select = new ilSelectInputGUI($field_obj->getName(), 'cdf[' . $field_obj->getId() . ']');
                 $select->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
                 $select->setOptions($field_obj->prepareSelectBox());
                 if ($field_obj->isRequired()) {
                     $select->setRequired(true);
                 }
                 $cdf->addSubItem($select);
                 break;
             case IL_CDF_TYPE_TEXT:
                 $text = new ilTextInputGUI($field_obj->getName(), 'cdf[' . $field_obj->getId() . ']');
                 $text->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
                 $text->setSize(32);
                 $text->setMaxLength(255);
                 if ($field_obj->isRequired()) {
                     $text->setRequired(true);
                 }
                 $cdf->addSubItem($text);
                 break;
         }
     }
     $this->form->addItem($cdf);
     return true;
 }
開發者ID:bheyser,項目名稱:qplskl,代碼行數:43,代碼來源:class.ilRegistrationGUI.php

示例2: addCustomFields

 /**
  * Add custom course fields
  * @param type $form
  * @param type $a_obj_id
  * @param type $a_type
  */
 public static function addCustomFields($form, $a_obj_id, $a_type, $a_mode = 'user')
 {
     global $lng;
     include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php';
     include_once 'Modules/Course/classes/Export/class.ilCourseUserData.php';
     if (!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($a_obj_id))) {
         return $form;
     }
     if ($a_mode == 'user') {
         $cdf = new ilNonEditableValueGUI($lng->txt('ps_' . $a_type . '_user_fields'));
         $cdf->setValue($lng->txt($a_type . '_ps_cdf_info'));
         $cdf->setRequired(true);
     }
     foreach ($cdf_fields as $field_obj) {
         switch ($field_obj->getType()) {
             case IL_CDF_TYPE_SELECT:
                 if ($field_obj->getValueOptions()) {
                     // Show as radio group
                     $option_radios = new ilRadioGroupInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
                     if ($field_obj->isRequired()) {
                         $option_radios->setRequired(true);
                     }
                     $open_answer_indexes = (array) $field_obj->getValueOptions();
                     foreach ($field_obj->getValues() as $key => $val) {
                         $option_radio = new ilRadioOption($val, $field_obj->getId() . '_' . $key);
                         // open answers
                         if (in_array($key, $open_answer_indexes)) {
                             $open_answer = new ilTextInputGUI($lng->txt("form_open_answer"), 'cdf_oa_' . $field_obj->getId() . '_' . $key);
                             $open_answer->setRequired(true);
                             $option_radio->addSubItem($open_answer);
                         }
                         $option_radios->addOption($option_radio);
                     }
                     if ($a_mode == 'user') {
                         $cdf->addSubItem($option_radios);
                     } else {
                         $form->addItem($option_radios);
                     }
                 } else {
                     $select = new ilSelectInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
                     #$select->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
                     $select->setOptions($field_obj->prepareSelectBox());
                     if ($field_obj->isRequired()) {
                         $select->setRequired(true);
                     }
                     if ($a_mode == 'user') {
                         $cdf->addSubItem($select);
                     } else {
                         $form->addItem($select);
                     }
                 }
                 break;
             case IL_CDF_TYPE_TEXT:
                 $text = new ilTextInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
                 #$text->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
                 $text->setSize(32);
                 $text->setMaxLength(255);
                 if ($field_obj->isRequired()) {
                     $text->setRequired(true);
                 }
                 if ($a_mode == 'user') {
                     $cdf->addSubItem($text);
                 } else {
                     $form->addItem($text);
                 }
                 break;
         }
     }
     if ($a_mode == 'user') {
         $form->addItem($cdf);
     }
     return $form;
 }
開發者ID:arlendotcn,項目名稱:ilias,代碼行數:79,代碼來源:class.ilMemberAgreementGUI.php


注:本文中的ilNonEditableValueGUI::setRequired方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。