Search code examples
phalcon

how to add multiple selected options in phalcon


i have used phalcon form element to implement the multiple select option.

$payment_method_id = new Select('payment_method_id',array(1 => 'PayPal', 2 => 'amazon', 3 => 'skrill'),array(
        'class'         => 'form-control',
        'multiple'      => 'multiple'
    ));
    $payment_method_id->setLabel('Select Payment Methods');     
    $payment_method_id->addValidators(array(
        new PresenceOf(array(
            'message' => 'The No Of Web Pages is required'
        ))
    ));
    $this->add($payment_method_id);

now i can add one option selected easily by using

$payment_method_id->setDefault(1);

but i want to select more then 1 option at a time like 'PayPal' and 'amazon' will be selected always. can any one help me on this problem?


Solution

  • You just have to use an array as parameter:

    $payment_method_id->setDefault(array(1,2));