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