• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Submit with form_button

#1
[eluser]predat0r[/eluser]
Is it possible to submit and validate a form with form_button? Why? I use JqueryUI for nice buttons, but the &lt;input&gt; type submit button renders differently than <button> types. When I use form_button with type=submit, nothing submitting, nor validating. I use CI's own server-side validation. And I don't want to ticker UI css at first.

Thanks

#2
[eluser]InsiteFX[/eluser]
The CodeIgniter Submit button is in the form_helper so you should be able to create a MY_form_helper
And make the changes you need.

InsiteFX

#3
[eluser]predat0r[/eluser]
[quote author="InsiteFX" date="1301593597"]The CodeIgniter Submit button is in the form_helper so you should be able to create a MY_form_helper
And make the changes you need.

InsiteFX[/quote]

thanks i'll try that!

#4
[eluser]andyy[/eluser]
Huh? I use <button type="submit"></button> all the time with absolutely no errors.

Can you post your code please? There should be no need to modify the helper..

#5
[eluser]predat0r[/eluser]
[quote author="andyy" date="1301694626"]Huh? I use <button type="submit"></button> all the time with absolutely no errors.

Can you post your code please? There should be no need to modify the helper..[/quote]

I set up a small form to test the button type, but also didn't work..

Anyway my orig. code:
Code:
echo form_open('site/test');
echo form_input('something');
$data = array(
    'type' => 'submit',
    'name' => 'send',
    'class' => 'uibutton'
);
echo form_button($data, 'Save');

$js2 = 'onClick="[removed]history.back();"';
$data = array(
    'name' => 'cancel',
    'class' => 'uibutton'
);
echo form_button($data, 'Cancel', $js2);
echo form_close();

JQuery code:
Code:
$(function() {
    $("a.uibutton, button.uibutton").button();
});

But without jquery ui doesn't submit or validate, too

#6
[eluser]andyy[/eluser]
Are you using ajax? Or are you just using jquery to submit the form?

#7
[eluser]predat0r[/eluser]
[quote author="andyy" date="1301797540"]Are you using ajax? Or are you just using jquery to submit the form?[/quote]

Latter. Somebody told me to do this way because it's working for him.

#8
[eluser]andyy[/eluser]
Jquery is not required to submit the form.

You'll need to modify your code, you're passing the parameters to the form_button() function incorrectly:

Code:
echo form_open('site/test');
echo form_input('something');
$data = array(
    'name'    => 'send',    // button name
    'content' => 'Save',    // this is the button text
    'type'    => 'submit',  // button type (important!)
    'class'   => 'uibutton'
);
echo form_button($data);

$data = array(
    'name'    => 'cancel',
    'content' => 'Cancel',
    'class'   => 'uibutton',
    'onclick' => '[removed]history.back(-1);' // you can pass inline statements through the parameter array
);
echo form_button($data);
echo form_close();

I highly recommend you read the CI guide on the form helper: http://ellislab.com/codeigniter/user-gui...elper.html

It contains the functions and how to properly pass parameters.

#9
[eluser]predat0r[/eluser]
thx i was lazy to fill out all elements, i know form_helper lib.. but did not solve my prob. i have elementary prob. with UI styleing copied the UI demo samples (there works) and not OK by me. Researching..

#10
[eluser]predat0r[/eluser]
In a separate css i had an input style that disturbed my UI css.. Now removing this tag error goes away.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.