fixed rendering of date block + fixed validation for dates

This commit is contained in:
Jonathan Labreuille
2016-08-16 14:41:53 +02:00
parent dc97d3115e
commit 213bca8050
3 changed files with 24 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
namespace MailPoet\Form\Block;
abstract class Base {
protected static function getInputValidation($block) {
protected static function getInputValidation($block, $extra_rules = array()) {
$rules = array();
if($block['id'] === 'email') {
@@ -37,8 +37,15 @@ abstract class Base {
$rules['required-message'] = __('Please select at least one option');
}
if($block['type'] === 'date') {
$rules['group'] = 'custom_field_'.$block['id'];
$rules['errors-container'] = '.mailpoet_error_'.$block['id'];
}
$validation = array();
$rules = array_merge($rules, $extra_rules);
if(!empty($rules)) {
$rules = array_unique($rules);
foreach($rules as $rule => $value) {