Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] TinyMCE and Form set_value problem
#5

[eluser]jjmax[/eluser]
Hi Lads,

Thanks for the replies.

@flaky
That last link seems to be pretty much what's happening with me too
I'm new to CI, is AR getting involved when I use the Form helper set_value function?

@Maglok
Thanks for your input I'll try your init on my page.
I've setup TinyMCE to edit html content that I've stored in the DB, the only difference here is I'm using set_value as opposed to pulling the data from the DB. I want to prevent my users from creating an articel with the same title as another one, but when I send them back to the article page I want to repopulate the form fields with the data they've already added. Here's the View code -
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html &gt;

&lt;head&gt;
        ...
    
    [removed][removed]
    [removed]
        tinyMCE.init({
            mode : "exact",
            elements: "main_content",
            plugins : "phpimage,fullscreen",
            relative_urls : false,
            remove_script_host : true,
            document_base_url : "http://localhost/raplom-cms/",
            theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifyright,justifycenter,justifyfull,separator,bullist, numlist,outdent,indent,separator,cut,copy,paste,separator,unlink,link,separator,phpimage,separator,formatselect,code,fullscreen",
            theme_advanced_blockformats : "h2,h3,h4,blockquote,dt,dd",
            theme_advanced_toolbar_align : "left",
            theme_advanced_buttons2 : "",
            theme_advanced_buttons3 : "",
            theme_advanced_toolbar_location : "top",
            theme : "advanced"
        });
    [removed]
        ...
    
&lt;/head&gt;

&lt;body&gt;
&lt;?php
        ...
        
        echo form_open("article/add_article");
        
        echo form_label('Title', 'title');
        echo form_input('title');
        
        echo form_label('Body', 'content');
        $data = array(
            'name'        => 'content',
            'id'        => 'main_content',
            'value'        => set_value('content'),
            'rows'        => '30',
        );
        echo form_textarea($data);
        
        echo form_label('Meta Description', 'meta_description');
        $data = array(
            'name'        => 'meta_description',
            'id'          => 'meta_description',
            'rows'        => '5',
        );
        echo form_textarea($data);
        
        echo form_label('Meta Keywords', 'meta_keywords');
        $data = array(
            'name'        => 'meta_keywords',
            'id'          => 'meta_keywords',
            'rows'        => '5',
        );
        echo form_textarea($data);
        
        echo form_submit('add_article', 'Add Article');
        
        echo form_close();
        
        ...
?&gt;
&lt;/body&gt;
and here's the Controller code -
Code:
function add_article()
        {
            $this->load->library('form_validation');
            $this->form_validation->set_error_delimiters('', '<br />');
            
            $this->form_validation->set_rules('title', 'Title', 'required|trim');
            $this->form_validation->set_rules('content', 'Content', 'required|trim');
            $this->form_validation->set_rules('meta_description', 'Meta Description', 'trim');
            $this->form_validation->set_rules('meta_keywords', 'Meta Keywords', 'trim');
            
            if($this->form_validation->run() == TRUE)
            {
                $this->load->model('article_model');
                
                $data = array(
                    'title'            => $this->input->post('title'),
                    'content'        => $this->input->post('content'),
                    'meta_description'    => $this->input->post('meta_description'),
                    'meta_keywords'        => $this->input->post('meta_keywords'),
                    'url'            => date('M-Y').'/'.url_title($this->input->post('title'), 'dash', TRUE)
                    );
                
                $query = $this->article_model->add_article($data);
                
                if($query == true)
                {                
                    $this->session->set_flashdata('success_message', 'You have successfully added an article');
                    redirect('article', 'refresh');
                }
                else
                {
                    $this->session->set_flashdata('fail_message', 'There is already another article with this title.<br />Just change the article title and resubmit it.');
                    redirect('article', 'refresh');
                }
            }
            else
            {
                $this->save_posted_data();
                $this->session->set_flashdata('fail_message', validation_errors());
                $_SESSION['flashdata'] = validation_errors();
                redirect('article', 'refresh');
            }
        }

Thanks again for the help. I'll try out your suggestions and let you know what happens.


Messages In This Thread
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 07:03 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 08:19 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 08:31 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 08:31 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 08:50 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 08:57 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 09:37 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 09:41 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 10:04 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 10:09 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 10:58 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-14-2010, 11:33 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-15-2010, 05:00 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-15-2010, 08:21 AM
[SOLVED] TinyMCE and Form set_value problem - by El Forum - 01-15-2010, 08:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB