0

with builder plugin, I try to validate my form fields. I used filterFields() to check fields on the fly. Now I want to make some date validation before DB save. I used the following code to clear a field like in filterFields().

// Called before the model is validated (bouton SAVE)
public function beforeValidate() {
    if ($this->date_begin > $this->date_end) {
        $this->attributes['date_end'] = null;      // clear date
    }
}

my problem is that I would like to refresh the form field or the complete form to reflect the modifications. Would somebody put me on the way to do it ? Thanks

Incremental
  • 27
  • 1
  • 8

1 Answers1

1

in your controller:

public function formAfterSave($model)
{ 
   return $this->formRenderFieldResult['#Form-field-Controller-date_end-group'] = $this->formRenderField('date_end', ['useContainer' => false]);
}

Where '#Form-field-Controller-date_end-group' is the field group name in your form, inspect element.