本文整理汇总了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;
}
示例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;
}