Welcome Guest, Not a member yet? Register   Sign In
where to put the css in a CI3 generated form?
#1

(This post was last modified: 04-17-2021, 10:59 AM by richb201.)

I have a form I am trying to create and instead of using HTML I am creating (and validating) with the built in form helper. Where do I put the css in this case?

PHP Code:
   public function index()
    {
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }
    


PHP Code:
    <style>
        body {font-familyArialHelveticasans-serif;}

        /* Full-width input fields */
        input[type=text] {
            width100%;
            padding12px 20px;
            margin8px 0;
            displayinline-block;
            border1px solid #ccc;
            box-sizingborder-box;
        }

        /* Set a style for all buttons */
        button {
            background-color#4CAF50;
            colorwhite;
            padding14px 20px;
            margin8px 0;
            bordernone;
            cursorpointer;
            width100%;
        }

        button:hover {
            opacity0.8;
        }

        /* Extra styles for the cancel button */
        .cancelbtn {
            widthauto;
            padding10px 18px;
            background-color#f44336;
        }

        /* Center the image and position the close button */
        .imgcontainer {
            text-aligncenter;
            margin24px 0 12px 0;
            positionrelative;
        }

        img.avatar {
            width40%;
            border-radius50%;
        }

        .container {
            padding16px;
        }

        span.psw {
            floatright;
            padding-top16px;
        }

        /* The Modal (background) */
        .modal {
            displaynone/* Hidden by default */
            positionfixed/* Stay in place */
            z-index1/* Sit on top */
            left0;
            top0;
            width100%; /* Full width */
            height100%; /* Full height */
            overflowauto/* Enable scroll if needed */
            background-colorrgb(0,0,0); /* Fallback color */
            background-colorrgba(0,0,0,0.4); /* Black w/ opacity */
            padding-top60px;
        }

        /* Modal Content/Box */
        .modal-content {
            background-color#fefefe;
            margin5auto 15auto/* 5% from the top, 15% from the bottom and centered */
            border1px solid #888;
            width80%; /* Could be more or less, depending on screen size */
        }

        /* The Close Button (x) */
        .close {
            positionabsolute;
            right25px;
            top0;
            color#000;
            font-size35px;
            font-weightbold;
        }

        .close:hover,
        .close:focus {
            colorred;
            cursorpointer;
        }

        /* Add Zoom Animation */
        .animate {
            -webkit-animationanimatezoom 0.6s;
            animationanimatezoom 0.6s
        
}

        @-webkit-keyframes animatezoom {
            from {-webkit-transformscale(0)}
            to {-webkit-transformscale(1)}
        }

        @keyframes animatezoom {
            from {transformscale(0)}
            to {transformscale(1)}
        }

        /* Change styles for span and cancel button on extra small screens */
        @media screen and (max-width300px) {
            span.psw {
                displayblock;
                floatnone;
            }
            .cancelbtn {
                width100%;
            }
        }
    </style
proof that an old dog can learn new tricks
Reply
#2

It should go with all your other css files in assets/css
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: 04-17-2021, 12:13 PM by richb201.)

Instead of using the CI3 generated form, I switched over to include the form in a template.  Now I can get the nice form I wanted. 

Now I am battling with the $_POST and also validation. I'd like to use CI3's form validation rules. Not sure if I can in this "bastardized" form. 

I have set the submit to go to a method  in the controller:

<form action="/index.php/Users_start_login/get_email" method="post">

and i do see the $_POST. I'd like to make sure it is a valid form of an email with:

$this->form_validation->set_rules('email', 'Email', 'required|valid_email);

before I check to see if it is sent to my authentication tool. 

One idea is to use:
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

  $emailErr = "Invalid email format";
}
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB