Welcome Guest, Not a member yet? Register   Sign In
is there any best practices document on Form Helper?
#1

(This post was last modified: 09-12-2020, 03:30 PM by richb201.)

I need to do a few forms and did find the form helper. Are there any best practices on doing forms in CI? I need some pulldowns and a group of 10 or so choices along with a numeric that represents a %. I'd love to see some nice examples of the type of things that can be done. For example, why would I want to hide values? What can i do with attributes?
proof that an old dog can learn new tricks
Reply
#2

Look in the the User guide under helpers it's there.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 09-13-2020, 08:54 AM by richb201.)

Insite, do you mean this page: https://codeigniter.com/userguide3/helpe...light=form. Yeah, I saw that! It tells you how to create a hidden field in a form, but not why to create a hidden field? It talks about Extra Attributes, but now what that would be used for? See below. What is a legend tag? What is a fieldset tag? Are these standard parts of PHP forms?

Code:
form_fieldset
([$legend_text = ''[$attributes = array()]])
Parameters:
  • [b]$legend_text[/b] (string) – Text to put in the <legend> tag

  • [b]$attributes[/b] (array) – Attributes to be set on the <fieldset> tag

Returns:
An HTML fieldset opening tag
Return type:
string


I'd like to set up a form with about 15 rows each with a radio button. Is there some recommended way to do this or do i just hand code it? The text for each row is coming from a mySQL table. 
proof that an old dog can learn new tricks
Reply
#4

(This post was last modified: 09-13-2020, 11:43 AM by richb201.)

Regardless, how do I architect this? I will be using FusionAuth. In FusionAuth, the user of my application can send an email to another person (who is already authenticated) who will be able to click on the link in it (notice, no password) and this will open myform,php on my server. Upon submit, the form data will be written to my mySQL table, and the form will close. How do I have the form.php work with the main Controller? Should it? Or should it be a separate, standalone program?

also

Right now i have this in my config.php

$config['base_url'] = 'http://localhost';
$config['index_page'] = 'index.php';

When I type localhost in my browser, my application runs my controller called Configure.php. Now if I want to run the form, not coming in through the main controller, how do I do this? I tried typing http://localhost/index.php/myform.php in my browser but get a 404  error. The construct in my Configure.php does all kind of things such as setup the database. So I think I need  to have the user of the form enter through the main "door" but I am concerned about security since they didn't login. Instead they just clicked on a link in the FusionAuth email. 
proof that an old dog can learn new tricks
Reply
#5

If you can grab the post data from the form with JavaScript you could then send the form data to your
controller using json.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(09-13-2020, 11:19 AM)richb201 Wrote: Now if I want to run the form, not coming in through the main controller, how do I do this? I tried typing http://localhost/index.php/myform.php in my browser but get a 404  error.

That’s not how CodeIgniter works. Why would you want to bypass the controller to call a php file directly?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#7

Thanks Beer. Here is where I am. I created a beautiful form via JotForms and downloaded it. I then changed it from a .html file to a .php file and am able to load it via load_view(). So far so good. My plan is to grab the $_POST values via CI/PHP from the submitted form. I am not quite there yet. I need to modify some of the fields in the form, prior to the user viewing it. I am not sure how to do this.

thx again for your comment.
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB