This patch creates a new function which extracts the right form values array from the $form_state so that every function that needs values gets right array. Additionally the settings form array always uses #tree = TRUE. This improvements will allow developers to embed the rules form from rules components correctly.
I also enabled AJAX for the add more button in the variable settings, since the issue #756762: AJAX should follow same rules for whether to call drupal_rebuild_form() as non-AJAX submissions has been fixed.

CommentFileSizeAuthor
#2 rules-1250724-2.patch10.78 KBsepgil
extracting_values.patch10.64 KBsepgil

Comments

fago’s picture

Component: User Interface » User interface
Status: Needs review » Needs work

>+ if (isset($value_state['provides'])) {

$value_state isn't a fitting variable name ;) Let's just use $values, or $form_values.

> // Enable AJAX once #756762 is fixed.
- // '#ajax' => rules_ui_form_default_ajax('none'),
+ '#ajax'
Does that work? IF yes, remove the comment too.

>Returns the right form values array from the $form_state.
Let's shortly describe that this is necessary if form is embedded somewhere.

Else the patch looks good to me.

sepgil’s picture

StatusFileSize
new10.78 KB

Corrected the issues.

sepgil’s picture

Status: Needs work » Needs review
fago’s picture

Status: Needs review » Fixed
   /**
+   * Returns the form values for the given form, possible being only a part of the whole form.
+   *
+   * In case the form is embedded somewhere, this function figures out the
+   * location of its form values and returns them for further use.
+   *
+   * @param $form
+   *   A form array, or an array of form elements to get the value for.
+   * @param $form_state
+   *   The form state as usual.
+   */

I fixed the comment to be like that.

Also, I've done some improvements like directly passing $form['settings'] and fixing the function when called during $form generation + I fixed a validation problem.

Committed it, thanks.

sepgil’s picture

Issue tags: +gsoc

Added GSoC tag.

Automatically closed -- issue fixed for 2 weeks with no activity.