Custom table - all my range inputs are saving to 1 not to value specified

Support MB Custom Table Custom table - all my range inputs are saving to 1 not to value specifiedResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30869
    Paul GearyPaul Geary
    Participant

    All my range inputs are saving to 1 not to value specified

    These are the field names in helper function

    
    public function table_fields() {
        $result = array(
            'Cntry. NL Rank'   => 'TINYINT(1) NOT NULL',
            'Cntry. NZ Rank'   => 'TINYINT(1) NOT NULL',
            'Cntry. SA Rank'   => 'TINYINT(1) NOT NULL',
    
    );
    return $result;
    
    }
    

    this is the table situation

    
    public function prefix_create_table() {
        if ( ! class_exists( 'MB_Custom_Table_API' ) ) {
            return;
        }
        MB_Custom_Table_API::create(
            'mb_ranks',
            $this->table_fields(),
            // array( 'email' )
        );
    }
    

    this is the input situation

    
    public function your_prefix_register_meta_boxes( $meta_boxes ) {
    
    $variable = $this->table_fields();
    $fields = array();
    foreach ($variable as $key => $value) {
        $fields[] = array(
            'id'   => $key,
            'name' => $key,
            'type' => 'range',
            // 'std'  => 1,
            'min'  => 1,
            'max'  => 5,
            'step' => 1,
        );
    }
    
    $meta_boxes[] = array(
        'title'        => 'Ranks',
        'storage_type' => 'custom_table',    // Important
        'table'        => 'mb_ranks', // Your custom table name
        'post_types' => ['projects'],
        'fields'       => $fields,
    );
    return $meta_boxes;
    
    }
    
    #30870
    Paul GearyPaul Geary
    Participant

    ok problem was using "Cntry. SA Rank" as the id - this is fine for the db but not for the input attributes (which demands cntry_sa_rank) so i changed some things around to fix this and it works

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.