Custom Fields
Re-Envisioned
Support MB Custom Table Custom table - all my range inputs are saving to 1 not to value specified

  • Creator
    Topic
  • #30869
    Resolved Paul 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;
    
    }
    
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #30870
    Paul 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 1 replies (of 1 total)
  • You must be logged in to reply to this topic.