Home Forums WC Vendors Pro Support Applying Character Limits to Custom Fields in the Product Form Reply To: Applying Character Limits to Custom Fields in the Product Form

#37981
Jamie
Keymaster

Hello,

You’re very close. When wanting to add validation rules you need to specify them as custom attributes in your field like this:

WCVendors_Pro_Form_Helper::input( array(  
				 'type'      => 'text',
				 'post_id'   => $object_id, 
				 'id'     => 'wcv_custom_product_includes_0', 
				 'placeholder'   => __( 'Included', 'wcvendors-pro' ), 
				 'desc_tip'    => 'true',
				 'custom_attributes' => array( 
		 			'data-rules' => 'max_length[120]', 

		 		)
			)
) );

cheers,

Jamie