标签: codeigniter-form-helper

Codeigniter - 日期格式 - 表单验证

我使用PHP.我正在使用以下表格,

<?php
    echo form_open('/register/create_new', $form_params);
?>

DOB: <input type="text" id="dob" name="reg[dob]">
     <input type="submit" value="Create Account" />
</form>
Run Code Online (Sandbox Code Playgroud)

在这里,#dobdd-mm-yyyy格式.

我的验证码是,

array(
  'field' => 'reg[dob]',
  'label' => 'DOB',
  'rules' => 'required'
)
Run Code Online (Sandbox Code Playgroud)

如何设置rules正确的日期验证?

php codeigniter codeigniter-form-helper

12
推荐指数
3
解决办法
5万
查看次数

在form_dropdown中添加class和id

有没有在CodeIgniter的form_dropdown中添加class和id属性的方法?我试过form_dropdown('name',$array,'class','id'),它没有改变任何东西,请告诉我如何实现它?

编辑:
使用我的下拉表格,form_dropdown('name',$array,set_value('someValue'),'id="myId"');如果我从浏览器中看到我的来源,它看起来像这样<select name="provinsi" id="provinsi_id">,但是如果我按照你的方式写form_dropdown('name',$array,set_value('someValue'),'class="myClass"','id="myId"');我的浏览器来源<select name="provinsi" class="myClass">

那是我的意思,
谢谢你

select codeigniter codeigniter-form-helper drop-down-menu

11
推荐指数
1
解决办法
3万
查看次数

如何使用选定的选项codeigniter创建一个多选框

嗨我正在使用codeigniter,我想添加multi select box到我的页面,

我看到了codeigniter用户指南示例,但它正在做的是在多选中设置值.

像这样

$options = array(
                  'small'  => 'Small Shirt',
                  'med'    => 'Medium Shirt',
                  'large'   => 'Large Shirt',
                  'xlarge' => 'Extra Large Shirt',
                );

$shirts_on_sale = array('small', 'large');

echo form_dropdown('shirts', $options, $shirts_on_sale);
Run Code Online (Sandbox Code Playgroud)

在这个像这样创建的多选框中

<select name="shirts" multiple="multiple">
<option value="small" selected="selected">Small Shirt</option>
<option value="med">Medium Shirt</option>
<option value="large" selected="selected">Large Shirt</option>
<option value="xlarge">Extra Large Shirt</option>
</select>
Run Code Online (Sandbox Code Playgroud)

它必须给出在$shirts_on_sale数组中选择的选项 ,但在我的情况下,我想创建一个多选,但dont want selected options 我试图传递一个空数组.但它不起作用

像这样

$array = array();
echo form_dropdown('shirts', $substore_details, $array); 
Run Code Online (Sandbox Code Playgroud)

如何创建没有选定项目的多项选择.请帮忙..............

php validation codeigniter codeigniter-form-helper

5
推荐指数
1
解决办法
2万
查看次数

在Codeigniter中选择框验证

我是Codeigniter的新手,我在选择框验证方面遇到了一些麻烦.我想要开始时的默认选择值.

<select name="schooGroups[]">
<option value="0">Select User Group</option>
<option value="1">Admin</option>
</select>
Run Code Online (Sandbox Code Playgroud)

如何在表单中创建必填字段并在选择零"0"值时显示错误消息.

php codeigniter codeigniter-form-helper

4
推荐指数
1
解决办法
3万
查看次数

Codeigniter - 表单助手set_select()

如何在codeigniter中的下拉列表中使用set_select()(表单助手的一部分):

它用于记住用户选择的选项.

$guide_options = array('investments' => 'Investments',
                       'wills' => 'Wills',
                       'tax-planning' => 'Tax planning',
                       'life-insurance' => 'Life insurance',
                       'currency-exchange' => 'Currency exchange',
                       'retirement-planning' => 'Retirement planning',
                       'international-healthcare' => 'International healthcare',
                       'savings-plans' => 'Savings plans',
                       'education-planning' => 'Education planning',
                       'sipps' => 'SIPPS',
                       'qrops' => 'QROPS',
                       'qnups' => 'QNUPS',
                       'mortgages' => 'Mortgages',
                       'other' => 'Other service'                       
                      );
echo form_dropdown('guide', $guide_options, 'investments');
Run Code Online (Sandbox Code Playgroud)

表格帮助指南:http://codeigniter.com/user_guide/helpers/form_helper.html

php codeigniter codeigniter-form-helper

4
推荐指数
1
解决办法
1万
查看次数

CodeIgniter form_validation-> run()总是返回false?

我是新手CodeIgniter,我一直在尝试实现表单提交功能,但每当我按"提交"表单页面时,只需刷新并且数据库不会更新!似乎$this->form_validation->run()总是返回假,但我不知道为什么.

所述控制器的功能如下:

public function write_prof_review($prof_id)
    {
        $this->load->model('Queries');
        // form stuff here
        $this->load->helper('form');
        $this->load->library('form_validation');

        $data['prof_id'] = $prof_id;
        if($this->form_validation->run() == FALSE){
            $this->load->view('create_prof_review', $data);
        }
        else {
            $this->Queries->submit_prof_review($prof_id, $this->USERID);
            $this->load->view('form_submitted');
        }       
    }
Run Code Online (Sandbox Code Playgroud)

这里是功能submit_prof_review()的模型:

function submit_prof_review($prof_id, $user_id)
    {
        $data = array(
            'course_code' => $this->input->post('course_code'),
            'easiness' => $this->input->post('easiness'),
            'helpfulness' => $this->input->post('helpfulness'),
            'clarity' => $this->input->post('clarity'),
            'comment' => $this->input->post('comment')
        );

    $average = round((($data['easiness'] + $data['helpfulness'] + $data['clarity'])/3),2);
    date_default_timezone_set('Asia/Hong_Kong');
    $date = date('m/d/Y h:i:s a', time());

    $data['average'] = $average;
    $data['date'] = …
Run Code Online (Sandbox Code Playgroud)

php codeigniter codeigniter-form-helper

3
推荐指数
1
解决办法
3万
查看次数

如何在 Codeigniter 框架中使用 form_input() 函数放置 HTML5 必填字段

我是 codeigniter 的新手。但现在我正在使用 codeigniter 开发一个项目。我的 HTML 代码是这样的:

<input type="text" class="get_started_frm_reg" name="first_name" required />
Run Code Online (Sandbox Code Playgroud)

现在我想通过函数 form_input() 函数来转换它。我写了这样的代码

$first_name=array(
     "name"=>"first_name",
     "class"=>"get_started_frm_reg",
     "type"=>"text"
);
Run Code Online (Sandbox Code Playgroud)

但我不明白如何输入必填字段。请帮助我。

codeigniter codeigniter-2 codeigniter-form-helper

3
推荐指数
1
解决办法
4462
查看次数

Codeigniter - 使用edit_unique编辑表单(重新填充)

似乎这里描述edit_unique函数- 在更新记录时验证CodeIgniter中的唯一性,杀死该set_value函数.

一切正常,这样的事......

echo form_input('username', set_value('username',$user->username));
Run Code Online (Sandbox Code Playgroud)

但是在使用edit_unique验证时,提交表单后该值为空.后变量是可以的,验证也没有错误 - 但是没有设置值.

知道如何解决这个问题吗?

php validation codeigniter codeigniter-form-helper

2
推荐指数
1
解决办法
3423
查看次数

CodeIgniter,表单助手 - 向元素添加类

所以我使用CodeIgniter Form帮助器创建了一个表单.我试图给一些表格元素一个类,但发生了一些奇怪的事情.我是这样做的:

echo form_input('title', $this->input->post('title'), 'class="titleInput"');
Run Code Online (Sandbox Code Playgroud)

当我检查元素时,它实际上显示了类在那里:

在此输入图像描述

但它不接受CSS文件中给出的任何属性.当我做一些丑陋的事情时:

echo form_input('title', $this->input->post('title'), style="height=30px");
Run Code Online (Sandbox Code Playgroud)

当我检查元素时,我得到了这个:

在此输入图像描述

但它实际上并没有对给定的样式做任何事情.

希望有人能帮到我这里!

css php codeigniter codeigniter-form-helper

2
推荐指数
1
解决办法
1万
查看次数

Codeigniter不允许我更新条目,因为某些字段必须是唯一的

所以我想做的是:

  1. 从数据库中提取用户数据,包括电子邮件地址,用户名

  2. 编辑它

  3. 保存

但我希望保持用户名和电子邮件的独特性.为此,我设置如下验证规则:

$this->form_validation->set_rules('firstname', 'First Name', 'required|min_length[2]|max_length[15]');
$this->form_validation->set_rules('lastname', 'Last Name', 'required|min_length[2]|max_length[15]');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');
$this->form_validation->set_rules('username', 'Username', 'required|min_length[4]|max_length[12]|is_unique[users.username]');
$this->form_validation->set_rules('password1', 'Password', 'required|matches[password2]');
$this->form_validation->set_rules('password2', 'Password Confirmation', 'required');
$this->form_validation->set_rules('group', 'User Group', 'required');
Run Code Online (Sandbox Code Playgroud)

正如你可以看到我有is_unique[users.username]is_unique[users.email]规则.但它不允许我使用此规则更新我的条目.

所以问题是,如何更新数据库条目,并保持这两个字段唯一(用户名和电子邮件)?

php mysql codeigniter codeigniter-form-helper

2
推荐指数
1
解决办法
3604
查看次数

Codeigniter 3 textarea

我试图将textarea中的行数限制为4但它给出了错误

Message: Array to string conversion
Run Code Online (Sandbox Code Playgroud)

这是我使用helper类的textarea代码

$textarea_options = array('class' => 'form-control','rows' => 4,   'cols' => 40);

echo form_textarea('vc_desc', set_value('vc_desc'),  $textarea_options);
Run Code Online (Sandbox Code Playgroud)

textarea codeigniter codeigniter-form-helper codeigniter-3

2
推荐指数
1
解决办法
9934
查看次数