Field Type "fieldset_text" as number

Support General Field Type "fieldset_text" as number

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4280
    Borsti26Borsti26
    Participant

    Hello,

    i want to create a fieldset but the field Type should be numbers only.
    the type "fieldset_text" would work perfect for my need if there would be a possibillity to allow for the user to only insert numbers like the type numbers do.

    Ist there a possibillity to create somting like that?

    Br
    René

    #4285
    Borsti26Borsti26
    Participant

    Maybe there is an option to setup in the function.php code to change the line 60 in the metabox fieldset-text.php file.

    $field['attributes']['type'] = 'text';

    #4295
    Anh TranAnh Tran
    Keymaster

    The fieldset_text always set the type attribute to text (in the normalization method), so the only way to change that to number is hook to the normalize filter, like this:

    add_filter( "rwmb_normalize_{$field_id}_field", function ( $field ) {
    	$field['attributes']['type'] = 'number';
    
    	return $field;
    } );
    #4298
    Borsti26Borsti26
    Participant

    Perfect!

    Thats fine for me.

    BR
    René

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Field Type "fieldset_text" as number’ is closed to new replies.