Skip to content
Snippets Groups Projects
Commit d8cca5e6 authored by Alex Barth's avatar Alex Barth
Browse files

Minor cleanups, add plugin form validation and submission.

parent fc65807e
No related branches found
No related tags found
No related merge requests found
......@@ -165,11 +165,10 @@ function feeds_ui_build_mapping_form(&$form_state, $feed) {
/**
* Edit plugin configuration.
*
* @todo: move plugin form generation into feed class.
*/
function feeds_ui_build_plugin_form(&$form_state, $feed) {
$form = array();
$form['#feed'] = $feed;
$form['plugins'] = array(
'#type' => 'fieldset',
'#title' => t('Plugins'),
......@@ -182,6 +181,21 @@ function feeds_ui_build_plugin_form(&$form_state, $feed) {
return $form;
}
/**
* Validation handler for feeds_ui_build_edit_form().
*/
function feeds_ui_build_plugin_form_validate($form, &$form_state) {
$form['#feed']->pluginFormValidate($form, &$form_state);
}
/**
* Submit handler for feeds_ui_build_edit_form().
*/
function feeds_ui_build_plugin_form_submit($form, &$form_state) {
$form['#feed']->pluginFormSubmit($form, &$form_state);
drupal_set_message(t('Saved configuration'));
}
/**
* Delete form.
*/
......
......@@ -110,6 +110,24 @@ class Feed extends FeedsConfigurable {
return $form;
}
/**
* Validation handler for pluginForm().
*/
public function pluginFormValidate($form, &$form_state) {
$form_state['values']['processors'] = array_filter($form_state['values']['processors']);
if (!count($form_state['values']['processors'])) {
form_set_error('processors', t('At least one processor needs to be enabled.'));
}
}
/**
* Submit handler for pluginForm().
*/
public function pluginFormSubmit($form, &$form_state) {
$this->addConfig($form_state['values']);
$this->save();
}
/**
* Import feed by using configured fetchers, parsers, processors.
*/
......@@ -289,8 +307,6 @@ class FeedsConfigurable {
/**
* Validation handler for configForm().
*
* @return unknown
*/
public function configFormValidate($form, &$form_state) {
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment