2010-02-08 8 views

risposta

21

Sì, è possibile:

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

Grazie per il suggerimento. Non l'ho ancora provato, ma appena l'avrò ti farò sapere. –

+1

Confermato in ZF 1.11.11. Questa risposta dovrebbe essere accettata invece. – LinusR

+0

Questa risposta dovrebbe essere accettata perché è quella giusta. Ho provato, funziona. – darpet

0

Funziona meglio sul tasto opzione. Ecco una funzione per disabilitare tutte le opzioni tranne quella attualmente attiva:

/** 
* 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); 
} 
Problemi correlati