Reputation: 58
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?
Upvotes: 0
Views: 4030
Reputation: 1
I got it working by simply adding multiple as yes on the view file, nothing on the form file.
{{ xform.render('user_id', ['id':'user_id','name':'user_id','multiple':true]) }}
Upvotes: 0
Reputation: 4715
You just have to use an array as parameter:
$payment_method_id->setDefault(array(1,2));
Upvotes: 3