function ClientsConnectionDrupalRESTTestEntityCreate::testForm in Web Service Clients 7.3
Creates the form element for the test.
This gets a form element with the basics in place. If your test needs input parameters, add form elements here.
Parameters
$element: A form element for the test's settings and button.
Return value
The form element with the test's additions.
File
- connections/
clients_drupal_rest/ clients_drupal_rest.testing.inc, line 192 - Contains classes for Client connection testing.
Class
- ClientsConnectionDrupalRESTTestEntityCreate
- Test entity creation on a Drupal Services connection.
Code
function testForm($element) {
$element['params']['entity_type'] = array(
'#type' => 'textfield',
'#title' => t('Entity type'),
'#description' => t("The entity type to create. (Note if using Services Entity this needs a prefix of 'entity')."),
'#required' => TRUE,
);
$sample_data = '{
"type":"article",
"title":"TITLE HERE",
"field_myfield":{"und":{"0":{"value":"VALUE"}}}
}
';
$element['params']['data'] = array(
'#type' => 'textarea',
'#rows' => 10,
'#title' => t('Data'),
'#description' => t('The POST data to pass for the entity, as either a JSON or PHP array.') . '<br>' . t('Sample data:') . '<br>' . "<pre>{$sample_data}</pre>",
);
$element['params']['data_type'] = array(
'#type' => 'radios',
'#title' => t('Data type'),
'#description' => t('The type of the POST data.'),
'#options' => array(
'json' => 'JSON',
'php' => 'PHP array',
),
);
return $element;
}