Welcome Guest, Not a member yet? Register   Sign In
form_open and Foundation Abide
#1

(This post was last modified: 02-18-2015, 05:44 AM by Chroma.)

Hi All,

Does anyone know of a way of using form_open to produce something like the following:

Code:
<form data-abide>

I know how to do this by writing the code by hand, but it would be nice to use the helpers.

Edit:

This is with CI 3.0 dev etc.
Reply
#2

Did you check out the part in the user guide showing how to add attributes to form_open()?
Reply
#3

(02-18-2015, 08:39 AM)CroNiX Wrote: Did you check out the part in the user guide showing how to add attributes to form_open()?

Yes, the attributes are of the form:

yyyy= "aaa"

Which is not what is needed. Here we only need the yyyy part without any of the equals part. If you know of a way of formatting the attributes to make them ignore the = part them I will be happy to learn that trick.
Reply
#4

According to the user guide for version 3, you can use a string instead of an array as the 2nd parameter.
Code:
echo form_open('email/send', 'class="email" id="myform" data-abide');
Reply
#5
Thumbs Up 

(02-18-2015, 08:45 AM)CroNiX Wrote: According to the user guide for version 3, you can use a string instead of an array as the 2nd parameter.


Code:
echo form_open('email/send', 'class="email" id="myform" data-abide');

Thank you, you are absolutely correct.

http://www.codeigniter.com/userguide3/he...elper.html

Clearly says that the second parameter can be a string. Even looking at it, I never saw the ' single quotes around the item.

Silly me.
Reply
#6

how to call a function in class with form_open()?

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Login extends CI_Controller {
public function 
__construct(){
parent::__construct();
$this->load->helper(array('form','url'));
$this->load->model('m_login');
$this->load->library('session');
}
public function 
index()
{
$this->load->view('v_login');
}
public function 
aksi(){
$data=array(
'username'=>$this->input->post('username'),
'password'=>$this->input->post('password')
);
$cek=$this->m_login->m_aksi($data);
if(
$cek == 1){
$x=$this->session->set_userdata($data);
redirect('login/sukses');
}else{
echo 
"login gagal";
}
}
public function 
sukses()
{
$data = array(
'username'=>$this->session->userdata('username')
);
$this ->load->view('v_sukses',$data);
}


i want to call function aksi in view with form_open, but not call function?
PHP Code:
<?php echo form_open('login/aksi');?>
Reply
#7

The first argument to form_open does not call a function, it simply sets the URL to which the form will be posted when you submit it. So you still have to add a submit button to your form or submit it with some other method before it will call the method in your controller.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB