To fix this, I am passing $form along. I kept the possibility to call node_validate with a $form.

Comments

chx’s picture

Version: 4.6.6 » x.y.z

And also, why I post with RTBC? Because the change is so minute. I will try to abstain from insant RTBC patches but this is really so.

tenrapid’s picture

StatusFileSize
new644 bytes

Attached patch contains a small change so that altered values are already visible in node preview.

chx’s picture

My patch was already committed just not set to fixed. Now, for tenrapid's patch, I honestly do not understand it. We do not change $edit in preview.

tenrapid’s picture

node_form_add_preview() calls drupal_validate_form(). But changes to the form values during form validation will not be visible in node previews as long as node_form_add_preview() gets only a copy of the global form values.

By receiving a reference to global form values it is ensured that node_preview() gets the possibly altered values.

chx’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

changes to form_values are made to the global form_values. I do not understand you.

tenrapid’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new1.08 KB

New patch. This is less circumstantial.

chx’s picture

Now, this makes much more sense.

chx’s picture

Status: Needs review » Reviewed & tested by the community

node_form_add_preview is an after build callback. After build callbacks are called with $form = $function($form, $form_values); so at first sight this patch makes no sense -- if form_values are passed already then why do we want to do a global for it? Because during validate it may change, that is. So please get this in before release.

killes@www.drop.org’s picture

applied to 4.7 branch

markus_petrux’s picture

Not sure how related to this, or how problematic...

Is it correct that node_search_validate() gets 3 arguments ($form_id, $form_values, $form)?

This callback is introducted like this:

    $form['#validate']['node_search_validate'] = array();

Sorry, if this isn't a problem. Just looks that only 2 arguments are to passed to node_search_validate() from _form_validate().

chx’s picture

1+2 is IMO three:

        $args = array_merge(array($elements), $args);
        // for the full form we hand over a copy of $form_values
        if (isset($form_id)) {
          $args = array_merge(array($form_id, $GLOBALS['form_values']), $args);
markus_petrux’s picture

Oh, I see. The 3rd argument is not use very often in validate functions so...

Thanks

killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Fixed

Drumm committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)