Question

I'm creating a select form element within FuelPHP's model _properties variable:

protected static $_properties = array(
    'category_id' => array(
        'data_type' => 'int',
        'label' => 'Category',
        'form' => array(
            'type' => 'select',
            'options' => array()
        )
    )
);

I want to set [category_id][form][options] to the result of an SQL query, however this obviously cannot be done within the class declaration and I've tried modifying the variable from with __construct(), this code is below but yielded errors.

 function _construct() {

     parent::__construct();

     self::$_properties['category_id']['form']['options'] = array('a');

}

My question is, how do I set the field options to something dynamic using FuelPHP?

Was it helpful?

Solution

You are almost there. Fuel provides a static constructor called init that will allow you to assign static properties.

function _init() {

     parent::_init();

     self::$_properties['category_id']['form']['options'] = array('a');

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top