G
G
Grizmar2014-08-09 21:20:44
Zend Framework
Grizmar, 2014-08-09 21:20:44

How to set 'disabled' attribute for 'select' tag in Zend Framework 2?

I create a form:
<?php
namespace City\Form;
use Zend\Form\Form;
class City extends Form
{
public function __construct() {
parent::__construct('city');
$this->setAttribute('action', 'getcity');
$this->setAttribute('method', 'post');
$this->setInputFilter(new \CIty\Form\CityFilter());
$this->add(array(
'name' => 'city',
'type' => 'Select',
'attributes' => array(
'id' => 'city',
),
'options' =>
'empty_option' => '--Select city--',
'value_options' => array(
'0' => 'Moscow',
'1' => 'St. Petersburg',
'2' => 'Dmitrov',
'3' => 'Another city',
),
),
));
}
}
How can I set the 'disabled' attribute for one of the option values, for example: 'Different city'?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DeFacto, 2014-08-12
@Grizmar

$this->getElement("city")->setAttrib("disable", array(3));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question