- This topic has 1 reply, 2 voices, and was last updated 2 years, 8 months ago by .
Not sure if this is purposefully like this or is a bug but if you use a group for the custom table column key like this
MB_Custom_Table_API::create( 'my_custom_table', array( 'address' => 'TEXT NOT NULL', 'phone' => 'TEXT NOT NULL', 'email' => 'VARCHAR(20) NOT NULL', ) );
$meta_boxes = array( 'title' => 'Meta Box Title', 'storage_type' => 'custom_table', 'table' => 'my_custom_table', 'fields' => array( array( 'name' => 'Address', 'id' => 'address', 'type' => 'group', 'fields' => array( array( 'name' => 'Line 1', 'id' => 'line_1', 'type' => 'text', ), array( 'name' => 'Line 2', 'id' => 'line_1', 'type' => 'text', ), ), ), array( 'name' => 'Phone', 'id' => 'phone', 'type' => 'text', ) ) );
Now if none of the group fields are filled out it returns NULL when saving in the DB, not sure if this is the intent and it easily can be altered by creating the table not using NOT NULL, but thought I would flag it in case as none of the other fields have this behaviour on saving.
Also it might be value adding to the docs that the baseline field ids have to match the table column key, and that the group id is required if nesting the fields in groups.
- You must be logged in to reply to this topic.