我正在使用codeigniter创建测试项目,我正在努力使用单选按钮和选项。 我想创建预先问题表格,例如6个不同的单选按钮选择和输入标签,如姓名,姓氏等(我成功实现)
当我填写必要的字段并将测试单选按钮设置为正确的值并点击提交按钮时,没有任何事情发生。我无法找到导致问题的原因。
我在这里使用表单助手(说使用set_radio的文档)
我尝试使用form_radio,set_radio等。您可以在下面找到我的示例
这是我的观点(我没有粘贴文本输入,因为该部分正在运行)
import os
import os.path
#From PIL
import Image
path2 = 'C:\Users\f'
def tiff_to_jpeg(path):
for root, dirs, files in os.walk(path):
for f in files:
a = f[:-4].replace(" ","")
b = a.replace("(","")
c = b.replace(")","")
c = c[2:]
c = '01' + c
print c
if os.path.splitext(os.path.join(root,f))[1].lower() == ".tif":
# If a jpeg is already present. Don't do anything.
if os.path.isfile(os.path.splitext(os.path.join(root, f))[0] + ".jpg"):
print "A jpeg file already exists for %s" %f
# If a jpeg is *NOT* present, create one from the tiff.
else:
outfile = os.path.join(path2,c) + ".jpg"
#outfile = os.path.splitext(os.path.join(root,f))[0] + ".jpg"
try:
im = Image.open(os.path.join(root,f))
print "Generating jpeg for %s" %f
im.thumbnail(im.size)
im.save(outfile, "JPEG", quality=100)
except Exception, e:
print e
path = 'C:\Users\f'
tiff_to_jpeg(path)
这是我的控制器
<div class="row">
<?php
$attributes = array(
"name" => "registrationform",
"id" => "msform"
);
echo form_open("yourself/register", $attributes);
?>
<!-- progressbar -->
<ul id="progressbar">
<li class="active"><span class="circle">1</span> APPLY</li>
<li class="active"><span class="circle">2</span> FORM</li>
<li><span class="circle">3</span> CHECK</li>
</ul>
<!-- FORM Yourself -->
<fieldset>
<div class="input-box">
<h2 class="title">What licence would you like?</h2>
<input type="radio" name="what_licence" value="1" <?php echo set_radio('what_licence', '1', TRUE); ?> /> Black and white?</label>
<input type="radio" name="what_licence" value="2" <?php echo set_radio('what_licence', '2'); ?> /> Colour?</label>
</div>
<div class="form-group">
<button name="submit" type="submit" class="btn btn-default">Signup</button>
<button name="cancel" type="reset" class="btn btn-default">Cancel</button>
</div>
</fieldset>
<!-- FORM Yourself -->
</form>
<?php echo form_close(); ?>
<?php echo $this->session->flashdata('msg'); ?>
</div>
<!-- row -->
&#39; what_licence&#39;是单选按钮不起作用 如果你能告诉我它会很棒。我变得秃顶,没有工作 提前致谢
答案 0 :(得分:0)
在哪里:$ this-&gt; form_validation-&gt; run()?
我的代码(没问题):
$this->form_validation->set_rules('what_licence', 'What licence', 'required|in_list[1,2]');
$this->form_validation->set_rules('initials', 'Initials', 'trim|required|alpha');
$this->form_validation->set_rules('lastname', 'Last Name', 'trim|required|alpha|min_length[3]|max_length[30]');
$this->form_validation->set_rules('email', 'Email ID', 'trim|required|valid_email|is_unique[yourself.email]');
$this->form_validation->set_rules('tel_number', 'Phone Number', 'required|numeric|min_length[9]|callback_uk_phone_check');
$this->form_validation->set_rules('address', 'Address', 'trim|required|alpha_numeric_spaces');
$this->form_validation->set_rules('post-code', 'Post Code', 'trim|required|alpha_numeric_spaces');
if ($this->form_validation->run()) {
echo "SUCCESS FORM";
$data = array(
'what_licence' => $this->input->post('what_licence'),
'initials' => $this->input->post('initials'),
'lastname' => $this->input->post('lastname'),
'email' => $this->input->post('email'),
'tel_number' => $this->input->post('tel_number'),
'address' => $this->input->post('address'),
'post-code' => $this->input->post('post-code'),
);
print_r($data);
}else {
echo validation_errors();
}
Pozdrawiam mistrzu:)