I created a custom field as below

class JFormFieldPaddyStatus extends JFormFieldList {

  protected $type = 'paddystatus';

  public function getOptions($id='') {
    $options = array();

    $options[0] = 'Raw';
    $options[1] = 'Dried';
    $options[2] = 'Grind';
    $options[3] = 'Ready';

    return $options;

In the database it stores the values as 0, 1 etc... When I show the status I want to show the corresponding names instead of its value.

At the moment I show the status as below

<td><?php echo $row->status; ?></td>

1 Answer 1


You should create a new instance of your field class and get options. Then echo status by key of $options array.

First 10 lines are needed only if you don't have classes loaded yet.

// Import JFormHelper if not exist

// Add your field path
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');

// Load JFormFieldPaddyStatus class

// Classes loaded
// New instance
$PaddyStatus = new JFormFieldPaddyStatus();

// Get options
$options = $PaddyStatus->getOptions();

// Show status
<td><?php echo $options[$row->status]; ?></td>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.