本文整理汇总了PHP中LiteralField::addExtraClass方法的典型用法代码示例。如果您正苦于以下问题:PHP LiteralField::addExtraClass方法的具体用法?PHP LiteralField::addExtraClass怎么用?PHP LiteralField::addExtraClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LiteralField
的用法示例。
在下文中一共展示了LiteralField::addExtraClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCompositeField
/**
* @return Comosite FieldSet with Categorys and Items
*/
function getCompositeField()
{
//create new composite field group for each category
$oCatFieldSet = new CompositeField();
// Set the field group ID
$oCatFieldSet->setID('Cat' . $this->ID);
$oCatFieldSet->addExtraClass('category');
//create new composite field group for each category
$oCatField = new TextField($this->ID . '_' . $this->FieldName, $this->Title, null, null);
$oCatField->addExtraClass('category-field');
//Add Category Percentage Field to the Form
$oCatFieldSet->push($oCatField);
if ($this->Description) {
$oCatDescField = new LiteralField($this->ID . '_Description', '<p class="category-field-desc">' . $this->Description . '</p>');
$oCatDescField->addExtraClass('category-field');
$oCatFieldSet->push($oCatDescField);
}
//Add item Composite Field to this Composite Field
//now get all of the items matched with this category
$oFormCategoryItems = self::FormCategoryItems();
foreach ($oFormCategoryItems as $item) {
$oCatFieldSet->push($item->getFormField());
}
return $oCatFieldSet;
}
示例2: EnquiryForm
public function EnquiryForm()
{
if (!Email::validEmailAddress($this->EmailTo) || !Email::validEmailAddress($this->EmailFrom)) {
return false;
}
if (!$this->EmailSubject) {
$this->EmailSubject = 'Website Enquiry';
}
$elements = $this->EnquiryFormFields();
if ($elements->count() == 0) {
return false;
}
/* Build the fieldlist */
$fields = new FieldList();
$validator = new RequiredFields();
$jsValidator = array();
foreach ($elements as $el) {
$key = $this->keyGen($el->FieldName, $el->SortOrder);
$field = false;
$type = false;
if ($el->FieldType == 'Text') {
if ($el->FieldOptions == 1) {
$field = new TextField($key, htmlspecialchars($el->FieldName));
} else {
$field = new TextareaField($key, htmlspecialchars($el->FieldName));
$field->setRows($el->FieldOptions);
}
} else {
if ($el->FieldType == 'Email') {
$field = new EmailField($key, htmlspecialchars($el->FieldName));
} else {
if ($el->FieldType == 'Select') {
$options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY);
if (count($options) > 0) {
$tmp = array();
foreach ($options as $o) {
$tmp[trim($o)] = trim($o);
}
$field = new DropdownField($key, htmlspecialchars($el->FieldName), $tmp);
$field->setEmptyString('[ Please Select ]');
}
} else {
if ($el->FieldType == 'Checkbox') {
$options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY);
if (count($options) > 0) {
$tmp = array();
foreach ($options as $o) {
$tmp[trim($o)] = trim($o);
}
$field = new CheckboxSetField($key, htmlspecialchars($el->FieldName), $tmp);
}
} else {
if ($el->FieldType == 'Radio') {
$options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY);
if (count($options) > 0) {
$tmp = array();
foreach ($options as $o) {
$tmp[trim($o)] = trim($o);
}
$field = new OptionsetField($key, htmlspecialchars($el->FieldName), $tmp);
}
} else {
if ($el->FieldType == 'Header') {
if ($el->FieldOptions) {
$field = new LiteralField(htmlspecialchars($el->FieldName), '<h4>' . htmlspecialchars($el->FieldName) . '</h4>
<p class="note">' . nl2br(htmlspecialchars($el->FieldOptions)) . '</p>');
} else {
$field = new HeaderField(htmlspecialchars($el->FieldName), 4);
}
} else {
if ($el->FieldType == 'Note') {
if ($el->FieldOptions) {
$field = new LiteralField(htmlspecialchars($el->FieldName), '<p class="note">' . nl2br(htmlspecialchars($el->FieldOptions)) . '</p>');
} else {
$field = new LiteralField(htmlspecialchars($el->FieldName), '<p class="note">' . htmlspecialchars($el->FieldName) . '</p>');
}
}
}
}
}
}
}
}
if ($field) {
if ($el->RequiredField == 1) {
$field->addExtraClass('required');
/* Add "Required" next to field" */
$validator->addRequiredField($key);
$jsValidator[$key] = $el->FieldType;
}
if ($el->PlaceholderText) {
$field->setAttribute('placeholder', $el->PlaceholderText);
}
$fields->push($field);
}
}
if ($this->AddCaptcha) {
$label = $this->CaptchaLabel;
$field = new CaptchaField('CaptchaImage', $label);
$field->addExtraClass('required');
//.........这里部分代码省略.........