CodeIgniter Forums
Submit with form_button - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Submit with form_button (/thread-40143.html)

Pages: 1 2


Submit with form_button - El Forum - 03-31-2011

[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


Submit with form_button - El Forum - 03-31-2011

[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


Submit with form_button - El Forum - 04-01-2011

[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!


Submit with form_button - El Forum - 04-01-2011

[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..


Submit with form_button - El Forum - 04-02-2011

[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


Submit with form_button - El Forum - 04-02-2011

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


Submit with form_button - El Forum - 04-03-2011

[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.


Submit with form_button - El Forum - 04-03-2011

[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-guide/helpers/form_helper.html

It contains the functions and how to properly pass parameters.


Submit with form_button - El Forum - 04-04-2011

[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..


Submit with form_button - El Forum - 04-04-2011

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