Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Pre-populate a select input from Orm Model with relationship
  • Hi,

    I want to use \Fieldset with my Model.

    ModelA Has One ModelB, therefor in the Fieldset of ModelA, i want to generate a select input on the attribute id_ModelB.

            'id_modelb' => array(
    'label' => 'the label',
    'default' => '',
    'null' => false,
    'form' => array('type' => 'select'),
    ),

    There is a way for pre-populate the select with all ModelB label (for example)  directly in the array ?

    Or i have to do this in the _init() function of the model ?
  • HarroHarro
    Accepted Answer
    There is no support (in Fieldset or ORM) to do this automatically.

    Best place to do it, it in the set_form_fields() method of the model, which is only called when you use add_model() on a fieldset. If you use _init() the population always happens when you load the model, even if you don't intend to generate a form...
  • Hm yes that's right, thanks Harro !

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion