Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8342635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:49:47+00:00 2026-06-09T05:49:47+00:00

I have a dropdown menu in my view called Placeholder – add_fields_placeholder with the

  • 0

I have a dropdown menu in my view called Placeholder – "add_fields_placeholder" with the values yes and no.

When no is selected I would like the placeholder value to be left out of the $formData array that generates the form html lines that are inserted into the database.

When yes is selected I would like the text from the Placeholder input box add_fields_placeholderValue to be submitted into the $formData array.

How would I achieve this?

  public function add()
    {

        $this->form_validation->set_rules('add_fields_name', 'Name', 'trim|required|xss_clean');
        $this->form_validation->set_rules('add_fields_value', 'Value', 'trim|xss_clean');
        $this->form_validation->set_rules('add_fields_class', 'Class', 'trim|xss_clean');
        $this->form_validation->set_rules('add_fields_placeholder', 'Placeholder', 'trim|required|xss_clean|callback_dropdown_check');
        $this->form_validation->set_rules('add_fields_type', 'Type', 'trim|required|xss_clean|callback_dropdown_check');

        if($this->form_validation->run() == FALSE)
        {
            $data['validation_errors'] = validation_errors('<div class="alert alert-error">', '</div>');
            $data['contentMangement'] = $this->options_model->systemOptions();
            $data['pageTitle'] = 'Add Fields';
            $this->load->view('_assets/dashHeader', $data);
            $this->load->view('dashboard/add_fields', $data);
            $this->load->view('_assets/footer');    


        }else{

            $fieldName = $this->input->post('add_fields_name', TRUE);
            $fieldValue = $this->input->post('add_fields_class', TRUE); 
            $fieldClass = $this->input->post('add_fields_defaultValue', TRUE);

            //Removes Caps & spaces
            $fieldNameStripped = strtolower(str_replace(" ", "", $fieldName));
            $fieldValueStripped = strtolower(str_replace(" ", "", $fieldValue));
            $fieldClassStripped = strtolower(str_replace(" ", "", $fieldClass));
            //Default Form Details

            $fieldLabel = '<label for="'. $fieldNameStripped . '">'. $fieldName. '</label>'."\n";

            $formData = array(
                                'name' => ''.$fieldNameStripped.'',
                                'id' => ''.$fieldNameStripped.'',
                                'value' => ''.$fieldValueStripped.'',
                                'class' =>''.$fieldClassStripped.'',
                                'placeholder' => ''
                            );


            if (isset($_REQUEST['add_fields_type']))
            {
                if($_REQUEST['add_fields_type'] == 'input')
                {
                    $fieldField = form_input($formData, TRUE);
                }

                if($_REQUEST['add_fields_type'] == 'textarea')
                {
                    $fieldField = form_textarea($formData, TRUE);
                }

                if($_REQUEST['add_fields_type'] == 'radiobutton')
                {
                    $fieldField = form_radio($formData, TRUE);
                }

                if($_REQUEST['add_fields_type'] == 'checkbox')
                {
                    $fieldField = form_checkbox($formData, TRUE);
                }

                $fieldTypeInsert = array(
                                        'name'  =>  ''.$fieldName.'',
                                        'type'  =>  ''.$_REQUEST['add_fields_type'].'',
                                        'label' =>  ''.$fieldLabel.'',
                                        'field' =>  ''.$fieldField.''   
                                        );

                $this->form_model->insertField($fieldTypeInsert);

                $data['validation_errors'] = '<div class="alert alert-success"><strong>Thank You</strong> Your Field Has Been Added</div>';
                $data['contentMangement'] = $this->options_model->systemOptions();
                $data['pageTitle'] = 'Add Fields';
                $this->load->view('_assets/dashHeader', $data);
                $this->load->view('dashboard/add_fields', $data);
                $this->load->view('_assets/footer');    

            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:49:49+00:00Added an answer on June 9, 2026 at 5:49 am

    You can do:

    $dropdown = $this->input->post('add_fields_placeholder', TRUE);
    $dropdown_value = '';
    if ($dropdown == 'yes') {
        $dropdown_value = 'yes';
    }
    
    $formData = array(
                     'name' => ''.$fieldNameStripped.'',
                     'id' => ''.$fieldNameStripped.'',
                     'value' => ''.$fieldValueStripped.'',
                     'class' =>''.$fieldClassStripped.'',
                     'placeholder' => $dropdown_value
                );    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have dropdown menu..which is dynamic.. How can get value of the last item
I have a simple dropdown menu: <form class=feedmenu align=center> <select onchange=showRSS1(this.value)> <option value=>Select an
I have a dropdown menu and when I click on the link I would
I have dropdown menu below where it retrieves the possible modules id's and their
I have a dropdown menu that pulls in text from a database column. The
I have a dropdown menu that I am using and can't quite get it
I have a dropdown menu on a website that works perfectly on all browsers
I have a dropdown menu that is filled by a mysql database. I need
I have a little dropdown menu similar <select> , which contolled from external js-function.
I have created a dropdown menu with jquery: here Everything is ok but in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.