2
如何根據變量值在Zend Framework中檢查複選框? 例如,我有$some_value = 'yes';
- 應選中複選框,否則取消選中。謝謝。Zend Form複選框已選中
如何根據變量值在Zend Framework中檢查複選框? 例如,我有$some_value = 'yes';
- 應選中複選框,否則取消選中。謝謝。Zend Form複選框已選中
以爲我會在這裏,你的問題寫得很差,但我會盡我所能。以下有幾個解決方案,我沒有對它們進行全面測試。給他們一個嘗試。
實施例1
// create your checkbox
$checkbox_element = new Zend_Form_Element_Checkbox("mycheckbox");
// Set the value to 1 if needed
if($some_value == "yes")
{
$checkbox_element->setValue(1);
}
實施例2
// Check if value is set
if($some_value == "yes")
{
// Create checkbox element and Set the attribute 'checked' to 'checked'
$checkbox_element = new Zend_Form_Element_Checkbox("mycheckbox", array("checked" => "checked");
}
else
{
// Othrewise create the checkbox which is not checked
$checkbox_element = new Zend_Form_Element_Checkbox("mycheckbox");
}
而內而外?你在問什麼? – Iznogood 2010-08-24 16:36:42
@Iznogood,我猜是'inside out',他的意思是'反過來'。 – shamittomar 2010-08-24 16:41:12
@shamittomar正確的,並沒有告訴我們很多關於他的問題。但是,嘿,如果你明白他可以自由回答。我認爲他應該發佈一些代碼和更好的解釋。 – Iznogood 2010-08-24 16:42:49