2010-02-08 11 views

Respuesta

21

Sí, es posible:

$element->setMultiOptions(array (
'songs' => 'songs', 
'lyrics' => 'lyrics', 
'artists' => 'artists' 
)); 
$element->setAttrib('disable', array('lyrics', 'songs')); 
+0

Gracias por la sugerencia. No lo he probado todavía, pero tan pronto como lo tenga, se lo haré saber. –

+1

Confirmado en ZF 1.11.11. Esta respuesta debe ser aceptada en su lugar. – LinusR

+0

Esta respuesta debe aceptarse porque es la correcta. Lo he intentado, funciona. – darpet

0

Funciona mejor en la tecla de opción. Aquí hay una función para deshabilitar todas las opciones excepto la actualmente activa:

/** 
* This function disables all options of the given selectElement, except for the active one 
* @param \Zend_Form_Element_Select $selectElement 
* @throws \Zend_Form_Exception 
*/ 
private function disableAllOtherOptions(\Zend_Form_Element_Select $selectElement) 
{ 
    $theOneAndOnlyActiveValue = $selectElement->getValue(); 
    $optionsToDisable = []; 
    foreach ($selectElement->options as $key => $option) { 
     if ($key <> $theOneAndOnlyActiveValue) { 
      $optionsToDisable[] = $key; 
     } 
    } 
    $selectElement->setAttrib('disable', $optionsToDisable); 
} 
Cuestiones relacionadas