开发者

XML - Need to add more child node with a loop

<field name="dob_day" type="list" default="select"
            description="COM_USERS_REGISTER_DOB_DAY_DESC"
            filter="string"
            label="COM_USERS_REGISTER_DOB_DAY_LABEL"
            message="COM_USERS_REGISTER_DOB_DAY_MESSAGE"
            required="true"
            >
            <option value="select">Day</option>
            <option value="1">1</option>
                    .......
                    .......
        </field>

This is the xml in joomla user registration.xml

I want to add days in a loop or something like:

for(i=1; i<=31;<i++):
  <option value="i">i<开发者_StackOverflow社区/option>
endfor

How can I do this in XML?


Why are you trying to use a loop for this. You can simply write these options manually. Besides you can not use any language in xml files.

If you wanted simple way for drop-down select with specific range of numbers there is a special Joomla field called "integer"

<field name="dob_day" type="integer" default="0"
    label="COM_USERS_REGISTER_DOB_DAY_LABEL"
    description="COM_USERS_REGISTER_DOB_DAY_DESC"
    message="COM_USERS_REGISTER_DOB_DAY_MESSAGE"
    first="0"
    last="31"
    step="1"
    required="true"
/>


If you want to extend a form in Joomla 1.6/1.7, your best bet is to use a plugin and attach yourself to the onFormPrepare event, which gives you the possibility to extend the form and especially overwrite existing elements with your own with additional options, etc. Look at the Joomla profile plugin, which does just that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜