简体   繁体   English

PHP单选按钮上的Simpletest断言?

[英]PHP Simpletest assertion on radio buttons?

I have one set of radio buttons: 我有一组单选按钮:

<input type="radio" id="edit-status-1" name="status" value="1" class="form-radio" />  <label class="option" for="edit-status-1">Active </label>

<input type="radio" id="edit-status-0" name="status" value="0" checked="checked" class="form-radio" />  <label class="option" for="edit-status-0">Blocked </label>

and I want a simpletest to figure out which one is checked by default. 我想要一个最简单的方法来找出默认情况下选中了哪个。 I can get to the page, but I don't know how to assert radio buttons. 我可以进入页面,但是我不知道如何声明单选按钮。

Thanks in advance. 提前致谢。

in Zend Framework, when you use zend forms, form->populate($data) get this task done but in pure php you need to compare values : 在Zend Framework中,当您使用zend表单时,form-> populate($ data)可以完成此任务,但是在纯PHP中,您需要比较值:

<input type="radio" name="name1" value="0" <?php echo ($_POST['name1']==0):'checked="checked"':'' ?> />
<input type="radio" name="name1" value="1" <?php echo ($_POST['name1']==1):'checked="checked"':'' ?> />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM