mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Deprecated FieldSet-specific methods from Form, namely dateFieldByName(), unsetDataFieldByName(), unsetFieldFromTab(), resetField()
This commit is contained in:
parent
7d46e7e751
commit
b3c08dba12
@ -309,7 +309,7 @@ JS;
|
||||
}
|
||||
|
||||
function sourceID() {
|
||||
$idField = $this->form->dataFieldByName('ID');
|
||||
$idField = $this->form->Fields()->dataFieldByName('ID');
|
||||
|
||||
// disabled as it conflicts with scaffolded formfields, and not strictly necessary
|
||||
// if(!$idField) user_error("ComplexTableField needs a formfield named 'ID' to be present", E_USER_ERROR);
|
||||
|
@ -355,7 +355,7 @@ class Form extends RequestHandler {
|
||||
* @return FormField
|
||||
*/
|
||||
function handleField($request) {
|
||||
$field = $this->dataFieldByName($request->param('FieldName'));
|
||||
$field = $this->Fields()->dataFieldByName($request->param('FieldName'));
|
||||
|
||||
if($field) {
|
||||
return $field;
|
||||
@ -526,9 +526,12 @@ class Form extends RequestHandler {
|
||||
* It will traverse into composite fields for you, to find the field you want.
|
||||
* It will only return a data field.
|
||||
*
|
||||
* @deprecated 3.0 Use Fields() and FieldList API instead
|
||||
* @return FormField
|
||||
*/
|
||||
function dataFieldByName($name) {
|
||||
Deprecation::notice('3.0', 'Use Fields() and FieldList API instead');
|
||||
|
||||
foreach($this->getExtraFields() as $field) {
|
||||
if(!$this->fields->dataFieldByName($field->getName())) $this->fields->push($field);
|
||||
}
|
||||
@ -564,16 +567,23 @@ class Form extends RequestHandler {
|
||||
/**
|
||||
* Unset the form's action button by its name.
|
||||
*
|
||||
* @deprecated 3.0 Use Actions() and FieldList API instead
|
||||
* @param string $name
|
||||
*/
|
||||
function unsetActionByName($name) {
|
||||
Deprecation::notice('3.0', 'Use Actions() and FieldList API instead');
|
||||
|
||||
$this->actions->removeByName($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the form's dataField by its name
|
||||
*
|
||||
* @deprecated 3.0 Use Fields() and FieldList API instead
|
||||
*/
|
||||
function unsetDataFieldByName($fieldName){
|
||||
Deprecation::notice('3.0', 'Use Fields() and FieldList API instead');
|
||||
|
||||
foreach($this->Fields()->dataFields() as $child) {
|
||||
if(is_object($child) && ($child->getName() == $fieldName || $child->Title() == $fieldName)) {
|
||||
$child = null;
|
||||
@ -1078,11 +1088,14 @@ class Form extends RequestHandler {
|
||||
/**
|
||||
* Resets a specific field to its passed default value.
|
||||
* Does NOT clear out all submitted data in the form.
|
||||
*
|
||||
*
|
||||
* @deprecated 3.0 Use Fields() and FieldList API instead
|
||||
* @param string $fieldName
|
||||
* @param mixed $fieldValue
|
||||
*/
|
||||
function resetField($fieldName, $fieldValue = null) {
|
||||
Deprecation::notice('3.0', 'Use Fields() and FieldList API instead');
|
||||
|
||||
$dataFields = $this->fields->dataFields();
|
||||
if($dataFields) foreach($dataFields as $field) {
|
||||
if($field->getName()==$fieldName) {
|
||||
|
@ -46,7 +46,7 @@ class ImageField extends FileIFrameField {
|
||||
$filter = create_function('$item', 'return (in_array("Folder", ClassInfo::ancestry($item->ClassName)) || in_array("Image", ClassInfo::ancestry($item->ClassName)));');
|
||||
|
||||
$form = parent::EditFileForm();
|
||||
$form->dataFieldByName('ExistingFile')->setFilterFunction($filter);
|
||||
$form->Fields()->dataFieldByName('ExistingFile')->setFilterFunction($filter);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ class RequestHandlingTest_Form extends Form {
|
||||
);
|
||||
|
||||
function handleField($request) {
|
||||
return $this->dataFieldByName($request->param('FieldName'));
|
||||
return $this->Fields()->dataFieldByName($request->param('FieldName'));
|
||||
}
|
||||
|
||||
function handleSubmission($request) {
|
||||
|
@ -32,7 +32,7 @@ class ComplexTableFieldTest extends FunctionalTest {
|
||||
}
|
||||
|
||||
function testCorrectNumberOfRowsInTable() {
|
||||
$field = $this->manyManyForm->dataFieldByName('Players');
|
||||
$field = $this->manyManyForm->Fields()->dataFieldByName('Players');
|
||||
$parser = new CSSContentParser($field->FieldHolder());
|
||||
|
||||
$this->assertEquals(count($parser->getBySelector('tbody tr')), 2, 'There are 2 players (rows) in the table');
|
||||
|
@ -170,11 +170,11 @@ class FormTest extends FunctionalTest {
|
||||
public function testFormMethodOverride() {
|
||||
$form = $this->getStubForm();
|
||||
$form->setFormMethod('GET');
|
||||
$this->assertNull($form->dataFieldByName('_method'));
|
||||
$this->assertNull($form->Fields()->dataFieldByName('_method'));
|
||||
|
||||
$form = $this->getStubForm();
|
||||
$form->setFormMethod('PUT');
|
||||
$this->assertEquals($form->dataFieldByName('_method')->Value(), 'put',
|
||||
$this->assertEquals($form->Fields()->dataFieldByName('_method')->Value(), 'put',
|
||||
'PUT override in forms has PUT in hiddenfield'
|
||||
);
|
||||
$this->assertEquals($form->FormMethod(), 'post',
|
||||
@ -183,7 +183,7 @@ class FormTest extends FunctionalTest {
|
||||
|
||||
$form = $this->getStubForm();
|
||||
$form->setFormMethod('DELETE');
|
||||
$this->assertEquals($form->dataFieldByName('_method')->Value(), 'delete',
|
||||
$this->assertEquals($form->Fields()->dataFieldByName('_method')->Value(), 'delete',
|
||||
'PUT override in forms has PUT in hiddenfield'
|
||||
);
|
||||
$this->assertEquals($form->FormMethod(), 'post',
|
||||
|
@ -229,10 +229,10 @@ class TableListFieldTest extends SapphireTest {
|
||||
))
|
||||
), new FieldList());
|
||||
|
||||
$table = $form->dataFieldByName('Tester');
|
||||
$table = $form->Fields()->dataFieldByName('Tester');
|
||||
$this->assertEquals(
|
||||
$table->Link('test'),
|
||||
sprintf('TableListFieldTest_TestController/TestForm/field/Tester/test?SecurityID=%s', $form->dataFieldByName('SecurityID')->Value())
|
||||
sprintf('TableListFieldTest_TestController/TestForm/field/Tester/test?SecurityID=%s', $form->Fields()->dataFieldByName('SecurityID')->Value())
|
||||
);
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ class TableListFieldTest extends SapphireTest {
|
||||
))
|
||||
), new FieldList());
|
||||
|
||||
$table = $form->dataFieldByName('Tester');
|
||||
$table = $form->Fields()->dataFieldByName('Tester');
|
||||
$rendered = $table->FieldHolder();
|
||||
|
||||
$this->assertContains('A-one', $rendered);
|
||||
|
Loading…
Reference in New Issue
Block a user