本文整理汇总了PHP中Field::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP Field::setType方法的具体用法?PHP Field::setType怎么用?PHP Field::setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field::setType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _parseFields
private function _parseFields($results)
{
$response = array();
foreach ($results as $result) {
$field = new Field();
$field->setName($result["Field"]);
$field->setType($result["Type"]);
$field->setPk($result["Key"] == 'PRI');
$response[] = $field;
}
return $response;
}
示例2: _parseFields
private function _parseFields($results, $pk)
{
$response = array();
foreach ($results as $result) {
$field = new Field();
$field->setName($result["field"]);
$field->setType($result["type"]);
$field->setPk($result["field"] == $pk["col"]);
$response[] = $field;
}
return $response;
}
示例3: testSetTypeException
/**
* Test setType exception
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid type
*/
public function testSetTypeException()
{
$object = new Field();
$object->setType('foo');
}
示例4: executeSaveField
/**
* Create a new field and save it to database
* @param sfWebRequest $request
* @return <type>
*/
public function executeSaveField(sfWebRequest $request) {
$data = $request->getPostParameters();
$fieldClass = new FieldClass();
$data = $fieldClass->prepareSaveData($data); // prepare the data to save, set color and writeprotected flag
// create parent element for the fields
$fieldObj = new Field();
$fieldObj->setTitle($data['createFileWindow_fieldname']);
$fieldObj->setType($data['createFileWindow_fieldtype']);
$fieldObj->setwriteprotected($data['createFileWindow_writeprotected']);
$fieldObj->setColor($data['createFileWindow_color']);
$fieldObj->save();
$id = $fieldObj->getId();
// add the child elements to the field, with the selected field type
switch ($data['createFileWindow_fieldtype']) {
case 'TEXTFIELD':
$textfield = new FieldTextfield();
$textfield->setFieldId($id);
$textfield->setRegex($data['fieldTextfield_regularexpression']);
$textfield->setDefaultvalue($data['fieldTextfield_standard']);
$textfield->save();
break;
case 'CHECKBOX':
// do nothing
break;
case 'NUMBER':
$numberfield = new FieldNumber();
$numberfield->setRegex($data['fieldNumber_regularexpression']);
$numberfield->setDefaultvalue($data['fieldNumber_standard']);
$numberfield->setComboboxvalue($data['fieldNumber_regularexpressioncombo']);
$numberfield->setFieldId($id);
$numberfield->save();
break;
case 'DATE':
$datefield = new FieldDate();
$datefield->setRegex($data['fieldDate_regularexpression']);
$datefield->setDateformat($data['fieldDate_format']);
$datefield->setDefaultvalue($data['fieldDate_date']);
$datefield->setFieldId($id);
$datefield->save();
break;
case 'TEXTAREA':
$data['fieldTextarea_content'] = $data['fieldTextarea_contenttype'] == 'plain' ? $data['fieldTextarea_textarea']: $data['fieldTextarea_htmlarea'];
$textarea = new FieldTextarea();
$textarea->setContent($data['fieldTextarea_content']);
$textarea->setContenttype($data['fieldTextarea_contenttype']);
$textarea->setFieldId($id);
$textarea->save();
break;
case 'RADIOGROUP':
$fieldClass->saveRadiogroup($id, $data); // save radiogroup
break;
case 'CHECKBOXGROUP':
$fieldClass->saveCheckboxgroup($id, $data); // save checkboxgroup
break;
case 'COMBOBOX':
$fieldClass->saveCombobox($id, $data); // save combobox
break;
case 'FILE':
$file = new FieldFile();
$file->setRegex($data['fieldFile_regularexpression']);
$file->setFieldId($id);
$file->save();
break;
}
$this->renderText('{success:true}');
return sfView::NONE;
}
示例5: testAdminCheckbox
/**
* Unit Test case-9 to test Check Boxes
*/
public function testAdminCheckbox()
{
$test = new Field(6);
$test->setType("checkbox");
$test->setIsRequired(true);
$test->setTextBefore("CHECK BOX!");
$test->setOptions("option1|-etm-|option2|-etm-|option3");
$html = $test->getAdminHtml();
/**
* test to see the textbeforechanges
*/
preg_match_all('/CHECK BOX!/', $html, $matches);
$this->assertEquals(2, count($matches[0]));
/**
* test to see we see the id 6
*/
preg_match_all('/etm_element_(\\d+)/', $html, $matches);
$this->assertEquals(6, $matches[1][0]);
/**
* test to see we see input types of type select
*/
preg_match_all('/<input type=\'checkbox\'/', $html, $matches);
$this->assertEquals(3, count($matches[0]));
}