Joomla 2.5 registration custom field as dropdown? - joomla

I added some extra field to Joomla 2.5. Everything working great. For example, I added "country" to registration.xml (components/com_users/models/forms):
<field name="country" type="text"
description="COM_USERS_REGISTER_COUNTRY_DESC"
filter="string"
label="COM_USERS_REGISTRATION_COUNTRY"
required="true"
size="40"
/>
But how to add a dropdown list? I want to give my users ability to select country from the list.
And similar question: I also added birthday field. How to add jQuery datepicker here?

In my opinion you should not edit Joomla core files. This could break your installation in future updates.
Although I don't recommend it, take a look at Standard form field and parameter types # Joomla Docs. At that page, see list for your dropdown list and calendar for your date.
Another way of adding extra fields would be with a extension. Check out:
ExtendedReg (commercial)
Community Builder

Joomla 2.5 has a 'profile' plugin to handle extra registration fields. You can edit that or write your own plugin. This avoids editing core files. Example of a country list using a database call (your database must have the table of counties). My table has country codes in two and three letters and I want to save the 3 letter code (example CAD).
<field
name="country"
type="sql"
id="country"
description="PLG_USER_PROFILE_FIELD_COUNTRY_DESC"
filter="string"
label="PLG_USER_PROFILE_FIELD_COUNTRY_LABEL"
message="PLG_USER_PROFILE_FIELD_COUNTRY_MESSAGE"
query="SELECT country_3_code as value, country_name as country FROM #__mycomponent_country
ORDER by country"
/>

For birthday use:
<field
name="birthday"
type="calendar"
label="Birth Day"
description="My Desc."
/>
And for country use the SQL as mentioned by #Gord Fisch

Related

Can't display my own id in apex:inputField in browser

I am very new to apex and just start to study how to add validation on the field. I am not able to do this from set up. In more detail I want to assign an id to apex:inputfield. I read a lot of information in the internet such as using partial id like http://www.kineticgrowth.com/javascript-visualforce-jquery-partial-id-selectors/
However know matter what I add in apex page, it doesn't show up inside the string. Here is my code:
<apex:pageBlock id="pageBlock" ...>
...
<apex:dataTable ... id="transTableBrandPurchase" ">
...
<apex:inputField id="eric_test" value="{!varBla}" required="true" />
when I check the browser in html it gets
<input id="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id273" maxlength="255" name="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id273" size="20" type="text">
Based on Salesforce reference I should get id="j_xxx:j_yyy ...:pageBlock:transTableManufacturerPurchase:eric_test"
People may say that I can just use "pageBlock:transTableManufacturerPurchase", I cann't because in this page we display then rows and the other rows look like similar:
<input id="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id275" name="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id275" >
Right now I am working on validation in visualforce page with Jquery.
My approach to assigning ID to elements in VF page is, give ID to all apex elements. Then use chrome inspect element option to find exact ID.
If you are using salesforce any repeat tags , , etc, salesforce will add additional numbering on your ID, to make sure that all elements have unique ID.

How to use "editor" field type in joomla "repeatable" form field?

I am developing a module for Joomla 3.3.6. I want to use "editor" field type in "repeatable" field in the xml file. The code I am using is as follows:
<field
name="fpssibtos_img1subs"
type="Repeatable"
icon="list"
label="GLOBAL_SUBS"
description="GLOBAL_SUBS_DESC"
default="{'fpssibtos_img1sub':['test']}">
<fields name="params">
<fieldset hidden="true" name="fpssibtos_img1subs_modal" repeat="true">
<field
name="fpssibtos_img1sub"
default="test"
type="editor"
label="GLOBAL_SUB"
description="GLOBAL_SUB_DESC"
filter="safehtml"/>
</fieldset>
</fields>
</field>
The problem is the editor is not editable, I mean you cannot type anything in it.
I am using CKEditor, I changed it to TinyMCE and others ,but the problem persists. I know that repeatable form field is still buggy ,but I thought some of you guys might know the fix to this particular problem.
In case anyone else comes across this problem, the repeatable form fields only support simple field types. This is apparently due to Joomla not having a simple way for scripts to interact.
Comment on the issue from one of the devs here and here.

Length of URL Language Code in Joomla 2.5

I need to change the content language URL Code for the french part of a Website to "costumes" (Found in the language manager under "content"). However the field stops after 7 letters, so that the last "s" is cut of.
I want to change that because the website-languages where set up as categories before, so that the french part is indexed by Google and others like that. Is there a way to allow 8 letters in this field?
Please try to change maxlength variable from file: /administrator/components/com_languages/models/forms/language.xml
<field name="lang_code" type="text"
description="COM_LANGUAGES_FIELD_LANG_TAG_DESC"
label="COM_LANGUAGES_FIELD_LANG_TAG_LABEL"
maxlength="7"
required="true"
size="10"
/>
<field name="sef" type="text"
description="COM_LANGUAGES_FIELD_LANG_CODE_DESC"
label="COM_LANGUAGES_FIELD_LANG_CODE_LABEL"
maxlength="7"
required="true"
size="10"
/>
This is a core change and every time you upgrade your joomla installation you have to check if it is getting overridden. If you want to create an override, you will need a 3rd party plugin.
Good Luck!

How to make a field required without data annotation

I am using the MvcContrib Grid to display a table on the page. I am using a custom column to produce a checkbox on the table so that the user can select multiple rows and submit the form.
I don't want the form to submit unless at least one checkbox has been selected. I could easily write this Javascript myself to enforce the validation, but I wanted to know how I could fit it in with the unobtrusive library supplied with MVC3.
I imagine I just need to set my inputs with the proper classes and attributes and then the scripts (validate and validate.unobtrusive) on the page should pick them up and mark them as needing validation, but I haven't been able to get the right combination thus far.
Here is the input that I am currently generating:
<input type="checkbox"
name="foo"
value="#item.foo"
class="input-validation-error"
data-val-required="Please select an option."
data-val="true" />
Try setting the data-val attributes on the item, then you have to tell jQuery you have new content to re-parse the form via something like:
$.validator.unobtrusive.parse($('#yourForm'));
where form is of course a reference to your form element.
There is also this great posting and jQuery has a few internal adapters you can call:
from http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-2
jQuery.validator.unobtrusive.adapters.addSingleVal("notequalto", "otherproperty", "mynotequaltofunction")
From my experience, a commonly overlooked mistake with displaying client-side validation is putting a Html.ValidationMessageFor(lambda) on the page.
Without that, no client-side validation will fire to prevent the form submit and/or display the message that is generated using annotations on the client-side.
Hope this helps.
<div class="editor-field">
<input class="text-box single-line"
data-val="true" data-val-number="The field Qty Available must be a number."
data-val-range="The field Qty Available must be between 0 and 120."
data-val-range-max="120" data-val-range-min="0"
data-val-required="The Qty Available field is required."
id="QtyOnHand" name="QtyOnHand" type="text" value="12" />
<span class="field-validation-valid" data-valmsg-for="QtyOnHand"
data-valmsg-replace="true"></span>
</div>
The tie-in between the data model annotations and the data-val-* attributes should be clear after reading the above code, but it's where the client side validation ties in might not be so obvious. Open the \Scripts\jquery.validate.unobtrusive.js file and search for "data-val". Right away you'll see that the JavaScript uses the data-val-, input- and field-* CSS classes to display/hide validation messages on the client.
The above is taken from this great article, which you might want to read in full.

Using Joomla 1.7 generic categories functions

Since 1.6, I believe, there's a generic way to use 'categories' in your own created components. The default Joomla components also use this. For example: the contacts, newsfeeds and weblinks components all use the generic com_categories functionality to achieve categorized content.
Currently I'm creating a component which also has categories so I'd like to use the generic Joomla category functions to achieve this.
The status: Currently I've got the following:
I've got a submenu 'categories' in my component which links to the generic categories component which some extra options. The options are there so the page will be redirected back to my component on save. This was pretty easy! But..
My problem: Now I'd like to add specific fields to my category, let's say: 'Category Moderator'.
So I've walked to the code of com_categories and in the following file 'administrator\components\com_categories\models\category.php' there is code (line 270) to look for specific component code, like the following:
// Looking first in the component models/forms folder
$path = JPath::clean(JPATH_ADMINISTRATOR."/components/$component/models/forms/$name.xml");
So the components looks (in my case) in the folder: administrator/components/mycomponent/models/forms/category.xml for specific component info.
Now, in the default category.xml of com_categories there's information about the edit screen, like the following:
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="JFIELD_TITLE_DESC"
class="inputbox"
size="40"
required="true"/>
So the title of the category is apparantly required..
So I thought I add a line to this file:
<field
name="moderator"
type="text"
label="JGLOBAL_MODERATOR"
description="JFIELD_MODERATOR_DESC"
class="inputbox"
size="40"
required="true"/>
Except that's not enough to add the input..
So I've looked in the administrator/components/com_categories/views/category/edit.php template for hints, how to achieve this. But there's no code to add specific inputs for my component (or I'm wrong ;))..
Fields are added pretty specific like:
<li><?php echo $this->form->getLabel('title'); ?>
<?php echo $this->form->getInput('title'); ?></li>
I've also looked if I can overide the edit.php somehow, but unfortunately I haven't found it..
Short: Anyone knows how to add generic fields to the category edit page?
You can do it by using plugins ( you can take a look at the built-in user profile plugin for an example: /plugins/user/profile ). But if you want to add a "Category Moderator", I think you could achieve it using ACL.

Resources