本文整理汇总了PHP中LiteralField::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP LiteralField::setAttribute方法的具体用法?PHP LiteralField::setAttribute怎么用?PHP LiteralField::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LiteralField
的用法示例。
在下文中一共展示了LiteralField::setAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
//.........这里部分代码省略.........