function editableviews_plugin_style_row_edit_table::validate in Editable Views 7
Validate that the plugin is correct and can be saved.
Return value
array An array of error strings to tell the user what is wrong with this plugin.
Overrides views_plugin_style::validate
File
Class
- editableviews_plugin_style_row_edit_table
- Plugin class for the Editable Table style.
Code
function validate() {
$errors = parent::validate();
$relationship_handlers = $this->display->handler
->get_handlers('relationship');
$field_handlers_grouped = $this->helper
->get_editable_field_handlers_grouped();
//dsm($field_handlers_grouped);
foreach ($relationship_handlers as $relationship_id => $relationship_handler) {
// We don't care about required relationships.
if ($relationship_handler->options['required']) {
continue;
}
//dsm($relationship_handler);
// We don't care if there are no editable fields on the relationship.
if (empty($field_handlers_grouped[$relationship_id])) {
continue;
}
if (!isset($relationship_handler->definition['editableviews_direction'])) {
$errors[] = t("The relationship '@relationship' is not compatible with editable fields that may cause creation of entities for empty data. The relationship should be set to be 'required'.", array(
'@relationship' => $relationship_handler->options['label'],
));
}
if (!isset($this->options['relationship_creation_bundle'][$relationship_id])) {
$errors[] = t("Display @display is set to use a editable fields and the '@relationship' relationship is not set to be required: the bundle of entities to create on this relationship must be set in the Editable Table options.", array(
'@display' => $this->display->display_title,
'@relationship' => $relationship_handler->options['label'],
));
}
}
return $errors;
}