本文整理汇总了PHP中FormField::setFieldType方法的典型用法代码示例。如果您正苦于以下问题:PHP FormField::setFieldType方法的具体用法?PHP FormField::setFieldType怎么用?PHP FormField::setFieldType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormField
的用法示例。
在下文中一共展示了FormField::setFieldType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfMsgForContent
function __construct($name, $text)
{
$this->name = $name;
$this->title = wfMsgForContent('formtitlepattern', $name);
$this->template = array();
$this->template[0] = wfMsgForContent('formtemplatepattern', $name);
$this->fields = array();
$this->namePattern = array();
$this->instructions = null;
# XXX: may be some faster ways to do this
$lines = explode("\n", $text);
foreach ($lines as $line) {
if (preg_match('/^(\\w+)=(.*)$/', $line, $matches)) {
if (strcasecmp($matches[1], 'template') == 0) {
$this->template[0] = $matches[2];
} elseif (preg_match('/template(\\d+)/i', $matches[1], $tmatches)) {
$this->template[intval($tmatches[1])] = $matches[2];
} elseif (strcasecmp($matches[1], 'namePattern') == 0) {
$this->namePattern[0] = $matches[2];
} elseif (preg_match('/namePattern(\\d+)/i', $matches[1], $tmatches)) {
$this->namePattern[intval($tmatches[1])] = $matches[2];
} elseif (strcasecmp($matches[1], 'title') == 0) {
$this->title = $matches[2];
} elseif (strcasecmp($matches[1], 'instructions') == 0) {
$this->instructions = $matches[2];
wfDebug(__METHOD__ . ": Got instructions: '" . $this->instructions . "'.\n");
} else {
wfDebug(__METHOD__ . ": unknown form attribute '{$matches['1']}'; skipping.\n");
}
} elseif (preg_match('/^(\\w+)\\|([^\\|]+)\\|(\\w+)(\\|([^\\|]+)(\\|(.*))?)?$/', $line, $matches)) {
# XXX: build an inheritance tree for different kinds of fields
$field = new FormField();
$field->setName($matches[1]);
$field->setLabel($matches[2]);
$field->setFieldType($matches[3]);
if (count($matches) > 4 && $matches[4]) {
$field->setDescription($matches[5]);
if (count($matches) > 6 && $matches[6]) {
$rawOptions = explode(',', $matches[7]);
foreach ($rawOptions as $rawOption) {
if (preg_match('/^(\\w+)=(.+)/', $rawOption, $optMatches)) {
$field->setOption($optMatches[1], $optMatches[2]);
} else {
wfDebug(__METHOD__ . ": unrecognized form field option: '{$rawOption}'; skipping.\n");
}
}
}
}
$this->fields[$field->name] = $field;
} else {
wfDebug(__METHOD__ . ": unrecognized form line: '{$line}'; skipping.\n");
}
}
}