function ReferenceOptionLimitEntityreferenceTestCase::rolPostAJAXCountryField in Reference field option limit 7
Wrapper around drupalPostAJAX() for updating the country field.
This allows for the differing structures required in the POST data array for different form elements.
Parameters
$country_node_title: The title of the country node to set on the country field.
$settings: The array of field settings passed to helperTestNodeCreateForm().
1 call to ReferenceOptionLimitEntityreferenceTestCase::rolPostAJAXCountryField()
- ReferenceOptionLimitEntityreferenceTestCase::helperTestNodeCreateForm in tests/
reference_option_limit.test - Helper to run tests.
File
- tests/
reference_option_limit.test, line 498 - Contains tests for the Reference option limit module.
Class
- ReferenceOptionLimitEntityreferenceTestCase
- Test use of the module with entityreference fields.
Code
function rolPostAJAXCountryField($country_node_title, $settings) {
if ($settings['widget'] . '-' . $settings['cardinality'] == 'options_buttons-' . FIELD_CARDINALITY_UNLIMITED) {
// Special case for checkboxes: because each checkbox is a separate form
// element, we have to unselect all the other values first.
$cities = reference_option_limit_test_entityreference_cities();
foreach (array_unique($cities) as $country_name) {
if ($country_name != $country_node_title) {
$excluded_node = $this
->getNodeByTitle($country_name);
$edit = array();
// Checkboxes must use FALSE -- see handleForm().
$edit["test_rol_er_country[und][{$excluded_node->nid}]"] = FALSE;
$this
->drupalPostAJAX(NULL, $edit, "test_rol_er_country[und][{$excluded_node->nid}]");
}
}
}
$post_data = $this
->getEditArray($country_node_title, $settings);
$this
->drupalPostAJAX(NULL, $post_data['edit'], $post_data['triggering_element']);
}