function ListFieldUITestCase::createListField

Helper function to create list field of a given type.

Parameters

string $type: 'list_integer', 'list_float', 'list_text' or 'list_boolean'

array $settings:

Throws

\FieldException

5 calls to ListFieldUITestCase::createListField()
ListFieldUITestCase::testDynamicListAllowedValuesText in modules/field/modules/list/tests/list.test
List (text) : test 'allowed values function' input.
ListFieldUITestCase::testListAllowedValuesBoolean in modules/field/modules/list/tests/list.test
List (boolen) : test 'On/Off' values input.
ListFieldUITestCase::testListAllowedValuesFloat in modules/field/modules/list/tests/list.test
List (float) : test 'allowed values' input.
ListFieldUITestCase::testListAllowedValuesInteger in modules/field/modules/list/tests/list.test
List (integer) : test 'allowed values' input.
ListFieldUITestCase::testListAllowedValuesText in modules/field/modules/list/tests/list.test
List (text) : test 'allowed values' input.

File

modules/field/modules/list/tests/list.test, line 445

Class

ListFieldUITestCase
List module UI tests.

Code

protected function createListField($type, $settings = array()) {
    // Create a test field and instance.
    $field = array(
        'field_name' => $this->field_name,
        'type' => $type,
    );
    if (!empty($settings)) {
        $field['settings'] = $settings;
    }
    field_create_field($field);
    $instance = array(
        'field_name' => $this->field_name,
        'entity_type' => 'node',
        'bundle' => $this->type,
    );
    field_create_instance($instance);
    $this->admin_path = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields/' . $this->field_name;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.