Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 8.18, custom field
- This topic has 7 replies, 2 voices, and was last updated 8 years, 3 months ago by
Steven Zahm.
-
AuthorPosts
-
04/30/2018 at 5:58 am #460778
Seun Tayo
ParticipantIs it possible to have several fields within a metabox when adding custom field?
thanks
04/30/2018 at 9:29 am #460822Steven Zahm
Keymaster@ Seun Tayo
RE: Is it possible to have several fields within a metabox when adding custom field?
Yes, it is possible. I’m assuming you’ve read the custom text field developer doc, correct?
The
fieldskey can be an array of fields. The sample code only shows a single text field. Each field you add will be within the same metabox.Hope this helps!
04/30/2018 at 3:04 pm #460849Seun Tayo
Participantthank you Steve for getting back. I am just learning the ropes here, I need help with the syntax for multiple fields.
I believe all of the below need to be repeated for different field within the meta box? is this correct? thank you:
array(
‘name’ => ‘Field Name’, // Change this field name to something which applies to you project.
‘show_label’ => TRUE, // Whether or not to display the ‘name’. Changing it to false will suppress the name.
‘id’ => ‘field_id’, // Change this so it is unique to you project. Each field id MUST be unique.
‘type’ => ‘text’, // This is the field type being added.
‘size’ => ‘regular’, // This can be changed to one of the following: ‘small’, ‘regular’, ‘large’
),04/30/2018 at 3:17 pm #460850Steven Zahm
Keymaster@ Seun Tayo
Yes, that is correct. The full code would be like this to add three fields:
// Register the metabox and fields. add_action( 'cn_metabox', 'cn_register_custom_metabox_and_text_field' ); function cn_register_custom_metabox_and_text_field() { $atts = array( 'title' => 'Metabox Name', // Change this to a name which applies to your project. 'id' => 'custom_one', // Change this so it is unique to you project. 'context' => 'normal', 'priority' => 'core', 'fields' => array( array( 'name' => 'Field Name', // Change this field name to something which applies to you project. 'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name. 'id' => 'field_id', // Change this so it is unique to you project. Each field id MUST be unique. 'type' => 'text', // This is the field type being added. 'size' => 'regular', // This can be changed to one of the following: 'small', 'regular', 'large' ), array( 'name' => 'Field Name', // Change this field name to something which applies to you project. 'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name. 'id' => 'field_id', // Change this so it is unique to you project. Each field id MUST be unique. 'type' => 'text', // This is the field type being added. 'size' => 'regular', // This can be changed to one of the following: 'small', 'regular', 'large' ), array( 'name' => 'Field Name', // Change this field name to something which applies to you project. 'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name. 'id' => 'field_id', // Change this so it is unique to you project. Each field id MUST be unique. 'type' => 'text', // This is the field type being added. 'size' => 'regular', // This can be changed to one of the following: 'small', 'regular', 'large' ), ), ); cnMetaboxAPI::add( $atts ); }Hope that helps!
05/02/2018 at 3:17 pm #461123Seun Tayo
ParticipantHello Steven,
I have created up to 8 additional fields under a meta box.
My question is – how do I ensure that all the 8 fields are exported (saved to the database, and displayed in forms and links?
I tried with a field within the metabox – I edited the card.php, created the slug as per the instructions here – (https://connections-pro.com/2014/06/04/quicktip-custom-template-override-files/) and here (https://connections-pro.com/2014/06/04/quicktip-custom-template-override-files/), I was able to see the single field when I exported the database, however this is not displayed in the front end.
Thank you
05/02/2018 at 3:54 pm #461125Steven Zahm
Keymaster@ Seun Tayo
RE: how do I ensure that all the 8 fields are exported (saved to the database, and displayed in forms and links?
By registering the fields… the data will be saved to the database. Try it. If you have successfully registered the fields, add a new entry. Add data in your custom fields. Save the entry. Now edit that entry, you will find the data saved to the database and can be edited.
RE: and displayed in forms and links?
To display in Form, Navigate to the Connections : Settings admin page and click the Form tab. Enable your metabox in the available options and save.
There is nothing special you need to do for link. :)
RE: I was able to see the single field when I exported the database, however this is not displayed in the front end.
Can you please describe how your are exporting the database?
To display the field in the template, please see the developer doc on how to display the custom field in a template. It has sample code. You will need to use it once per custom field that you registered.
05/02/2018 at 6:29 pm #461127Seun Tayo
ParticipantGood evening Steven
thank you for quick response.
Let me rephrase my question –
becuase I am dealing with multiple field within a metabox, where do I add additional field within this code?
$text = $entry->getMeta( array( 'key' => 'field_id', // This should match exactly the field id used when registering the custom field. 'single' => TRUE // Do not change this. ) ); if ( ! empty( $text ) ) echo '' . esc_html( $text ) . '';will I have to duplicate the below and change the field_id to correspond with each field_id?
'key' => 'field_id', // This should match exactly the field id used when registering the custom field. and when this is done, in the exp`enter code here`ort and import code snippets, I assume I am repeating the below:‘field’ => ‘field_mn’, // The field_id should match exactly the field id used when registering the custom field.
‘type’ => 5,
‘fields’ => ”,
‘table’ => CN_ENTRY_TABLE_META,
‘types’ => NULL,05/03/2018 at 9:22 am #461171Steven Zahm
Keymaster@ Seun Tayo
RE: becuase I am dealing with multiple field within a metabox, where do I add additional field within this code?
You would add that to the template
card.phpfile as explained in the developer doc.RE: will I have to duplicate the below and change the field_id to correspond with each field_id?
Yes, you will have to duplicate the code, once for each field your registered.
Hope this helps!
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.
