Populating Drop Downs During CB Plugin Install

13 years 9 months ago #137262 by gordonbanderson
Populating Drop Downs During CB Plugin Install was created by gordonbanderson
hello!

I have experience in other open source PHP tools (mainly Moodle and Silverstripe) but I am new to both Joomla and Community Builder. I've hit a stumbling block and as such seek some advice as to best practice with a problem I am having.

I am trying to write a plugin to split a user profile into several tabs, with fields of different types and values. I've got as far as creating the tabs with text fields and these are appearing as I would expect.

A snippet from my XML install file looks like this:

[code:1]<fields>
<field title="Years" name="cb_studentnyearssecondary"
description="Number of years at secondary school"
type="text" registration="1"
profile="1" readonly="0" params="" />

<field title="Do You Smoke?" name="cb_studentsmoker"
description="Do you smoke?"
type="select" registration="1"
profile="1" readonly="0" params="" />

...
SNIPPED
....
</fields>[/code:1]


I have 2 problems that I am unsure how to resolve

1) How do I make the field required? I tried adding 'required="1"' i the field tag in the XML but this did not appear to work

2) Secondly I wish to pre-populate the drop down above with a Yes / No answer. I can see how to do this in SQL as follows:

[code:1]insert into jos_comprofiler_field_values(fieldid, fieldtitle, ordering, sys) values
((select fieldid from jos_comprofiler_fields where name = 'cb_studentsmoker' limit 1), 'No', 1, 0);

insert into jos_comprofiler_field_values(fieldid, fieldtitle, ordering, sys) values
((select fieldid from jos_comprofiler_fields where name = 'cb_studentsmoker' limit 1), 'Yes', 0, 0);[/code:1]


Should I just add these to the <query> section of the install XML file, or is there some other sub tag or attribute of the XML for <field>s that I have not found out about that can be used instead.


Kind regards

Gordon

Please Log in to join the conversation.

13 years 9 months ago #137326 by krileon
Best I can suggest is review document subscriber available ajax text and file fieldtype plugins as well as other CB plugins (many of which add fields) such as Facebook or Twitter plugins. Alternatively you can wait for the CB API documentation which is currently in development. We don't assist with personal development tasks, sorry.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.242 seconds

Facebook Twitter LinkedIn