Jump to content

Specific custom field variable in template files


dexus

Recommended Posts

I know that custom fields are added like this in template files:

 

{foreach key=num item=customfield from=$customfields}
<tr><td class="fieldarea">{$customfield.name}</td><td>{$customfield.input} {$customfield.required}</td></tr>
{/foreach}

 

but how can I add just one specific field, for example I need just custom field with id=3 somwhere in template file.

Link to comment
Share on other sites

I just realised how... :) I never used smarty before, but I should just use my brain :)

 

If someone like to know you can get the specific custom field like this:

 

<tr><td class="fieldarea">{$customfields[1].name}</td><td>{$customfields[1].input} {$customfields[1].required}</td></tr>

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
I just realised how... :) I never used smarty before, but I should just use my brain :)

 

If someone like to know you can get the specific custom field like this:

 

<tr><td class="fieldarea">{$customfields[1].name}</td><td>{$customfields[1].input} {$customfields[1].required}</td></tr>

 

Hi all,

 

have implemented this in a number of templates, and works great, especially for "new registration" type pages.

However, for "modify registration" or similar pages, any existing values are not populated.

 

I believe this function was being performed by the first line of the following

{if $customfields}<tr><td class="fieldarea"></td></tr>{/if}

{foreach key=num item=customfield from=$customfields}

<tr><td class="fieldarea">{$customfield.name}</td><td>{$customfield.input} {$customfield.required}</td></tr>

{/foreach}

 

however, I now have my custom fields field presenting individually

<tr><td class="fieldarea">{$customfields[5].name}</td><td>{$customfields[5].input} {$customfields[5].required} </td></tr><!--Business Size-->

 

I believe that I need to insert the code (or similar) {$customfields.1.value}, but can't find the correct syntax anywhere.

 

Obviously if the field is blank, the value would be empty, but where there is a value, i would like to be able to have that field populated.

 

I have approximately 10 custom field in play, with another 30 or 40 to come.

 

PS, i get the concept of default values in regular fields (value="{$fieldname}) (sic), but duplicating this for custom fields isn't obvious.

 

can anyone help?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated