• Resolved tuux

    (@pixeldt)


    Hi,

    Before, thanks for your great plugin. You did a great work with it!

    After update WordPress to v4.6.1 and Metabox to v4.9, the “validation” configured to a custom field assigned to a custom-post-type just stops working.

    
    add_action( 'init', 'codex_book_init' );
    function codex_book_init() {
    	$labels = array(
    		'name'               => _x( 'Agenda', 'post type general name', 'your-plugin-textdomain' ),
    		'singular_name'      => _x( 'Agenda', 'post type singular name', 'your-plugin-textdomain' ),
    		'menu_name'          => _x( 'Agenda', 'admin menu', 'your-plugin-textdomain' ),
    		'name_admin_bar'     => _x( 'Agenda', 'add new on admin bar', 'your-plugin-textdomain' ),
    		'add_new'            => _x( 'A?adir Nuevo', 'book', 'your-plugin-textdomain' ),
    		'add_new_item'       => __( 'A?adir Nuevo Item', 'your-plugin-textdomain' ),
    		'new_item'           => __( 'Nuevo Item', 'your-plugin-textdomain' ),
    		'edit_item'          => __( 'Editar Item', 'your-plugin-textdomain' ),
    		'view_item'          => __( 'Ver Item', 'your-plugin-textdomain' ),
    		'all_items'          => __( 'Tdos los Items', 'your-plugin-textdomain' ),
    		'search_items'       => __( 'Buscar Item', 'your-plugin-textdomain' ),
    		'parent_item_colon'  => __( 'Item padre:', 'your-plugin-textdomain' ),
    		'not_found'          => __( 'No se encontraron items.', 'your-plugin-textdomain' ),
    		'not_found_in_trash' => __( 'No se encontraron items en la papelera.', 'your-plugin-textdomain' )
    	);
    	$args = array(
    		'labels'             => $labels,
            'description'        => __( 'Agenda de próximos eventos', 'your-plugin-textdomain' ),
    		'public'             => true,
    		'publicly_queryable' => true,
    		'show_ui'            => true,
    		'show_in_menu'       => true,
    		'query_var'          => true,
    		'rewrite'            => array( 'slug' => 'agenda' ),
    		'capability_type'    => 'post',
    		'has_archive'        => true,
    		'hierarchical'       => true,
    		'menu_position'      => 20,
    		'menu_icon'          => 'dashicons-calendar-alt',
            //'taxonomies'         => array( 'category' ),
    		'supports'           => array( 'title' )
    	);
    	register_post_type( 'agenda', $args ); 
    }
    
    /* ========================================================================== */
    
    add_filter( 'rwmb_meta_boxes', 'single_autor_register_meta_boxes' );
    function single_autor_register_meta_boxes( $meta_boxes ) {
        $prefix = 'ag_box_';
        // 1st meta box
        $meta_boxes[] = array(
            'id'         => 'articulos_fields',
            'title'      => __( 'Descripción', 'textdomain' ),
            'post_types' => array( 'agenda'),
            'context'    => 'normal',
            'priority'   => 'high',
            'fields' => array(        
                 array(
                    'name'  => __( 'Fecha y Hora del evento', 'textdomain' ),
                    'id'    => $prefix . 'date',
                    'type'  => 'datetime',
                ), 
                array(
                    'name'  => __( 'Nombre del evento', 'textdomain' ),
                    'id'    => $prefix . 'name',
                    'type'  => 'text',
                ), 
                array(
                    'name'  => __( 'Lugar del evento', 'textdomain' ),
                    'id'    => $prefix . 'place',
                    'type'  => 'text',
                ),
                array(
                    'name'  => __( 'Ciuadad del evento', 'textdomain' ),
                    'id'    => $prefix . 'city',
                    'type'  => 'text',
                ), 
            ),
          'validation' => array(
    			'rules'    => array(
    				"{$prefix}date" => array(
    					'required'  => true,
    				),
    			),
    			// optional override of default jquery.validate messages
    			'messages' => array(
    				"{$prefix}date" => array(
    					'required'  => esc_html__( 'Fields is required', 'your-prefix' ),
    				),
    			),
    		) 
        );
        return $meta_boxes;
    }

    Any idea how can I fix this?

    • This topic was modified 8 years, 6 months ago by tuux.
    • This topic was modified 8 years, 6 months ago by tuux.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Validation Issue after WordPress 4.6.1 / Metabox 4.9 Update’ is closed to new replies.