Jump to content

Сustomfield conclusion


Artjom

Recommended Posts

Hello everyone,

how to make that conclusion was by a single field, rather than all at once each?

core/templates/profile_edit.tpl

<?php
if($customfields)
{
	foreach($customfields as $field)
	{
		echo '<dt>'.$field->title.'</dt>
			  <dd>';

		if($field->type == 'dropdown')
		{
			$field_values = SettingsData::GetField($field->fieldid);				
			$values = explode(',', $field_values->value);


			echo "<select name=\"{$field->fieldname}\">";

			if(is_array($values))
			{						
				foreach($values as $val)
				{
					$val = trim($val);

					if($val == $field->value)
						$sel = " selected ";
					else
						$sel = '';

					echo "<option value=\"{$val}\" {$sel}>{$val}</option>";
				}
			}

			echo '</select>';
		}
		elseif($field->type == 'textarea')
		{
			echo '<textarea class="customfield_textarea"></textarea>';
		}
		else
		{
			echo '<input type="text" name="'.$field->fieldname.'" value="'.$field->value.'" />';
		}

		echo '</dd>';
	}
}
?>

Example:

not so

PROFILE SETTINGS

VATSIM ID

VATSIM NAME

YOUR SYSTEM

but so

PROFILE SETTINGS

YOUR SYSTEM

VATSIM SETTINGS

VATSIM ID

VATSIM NAME

This code isn't work...

<?php $customfield = SettingsData::GetField ($field->fieldid , 'VATSIM_NAME' ); {echo '<input type="text" name="VATSIM_NAME" value="'.$field->value.'" />' ;}?>

Link to comment
Share on other sites

I think it's SettingsData::getFieldValue - check the API docs, I can't remember off the top of my head

Thank you,

This code works

    <?php 
   echo '<dt>VATSIM ID</dt>
<dd>';
   $customfield = PilotData::GetFieldValue ($userinfo->pilotid , 'VATSIM ID' ); 
   {
   echo '<input type="text" name="VATSIM ID" value="'.$customfield.'" />' ;
   }
   echo '</dd>';
   ?>

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

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.   Restore formatting

  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.

Loading...
×
×
  • Create New...