Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
html quotes gets encoded :(
  • Hi, After some reading on the forums i found out you can prevent variables to be encoded using (false as third parameter):
    $this->template->content = View::factory('welcome/index_news')
        ->set('news', $news, false);
    

    But for some reason when i use a wysiwyg editor, my quotes do get encoded (before each " a / is being written).
    What am i doing wrong?
  • Your data is not encoded by the view since you used the false parameter. But it's still encoded by the template. Use false to assign the data to the template too:
    $this->template->set('content', View::forge(), false);
    
  • K at first the forge() wasnt reconized so I updated the core package to 1.1
    Now after some fixes I get following error:
    Call to a member function show_errors() on a non-object

    controller method:
    public function action_add ()
     {
      $val = Validation::factory('add_news');
            $val->add('caption', 'Titel')->add_rule('required');
            $val->add('body', 'Body')->add_rule('required');
            
            if ($val->run())
            {   
                $news = new Model_News(array(
                    'caption' => $val->validated('caption'),
                    'message' => $val->validated('body'),
        'archieved' => 0,
                    'time_posted' => Date::factory()->get_timestamp(),
                ));
    
                if ($news->save())
       {
        Session::set_flash('success', 'Nieuws toegevoegd.');
        Response::redirect('admin/news');
       }
       else
       {
        Session::set_flash('error', 'Er is een fout opgetreden, gelieve opnieuw te proberen!');
        Response::redirect('admin/news/add');
       }
            }
            
      $this->template->title = 'Nieuws toevoegen';
      $this->template->set('content', View::forge('admin/news_add'), false)
      //$this->template->content = View::factory('admin/news_add')
       ->set('val', Validation::instance('add_news'), false);
     }
    

    view:
    <h2>Nieuws toevoegen</h2>
    <p>Voeg nieuws toe, door volgende gegevens in te vullen.</p>
    
    <div class="options">
     <div class="option"><?php echo Html::anchor('admin', 'Admin'); ?></div>
     <div class="option"><?php echo Html::anchor('admin/category', 'Categorien'); ?></div>
     <div class="option"><?php echo Html::anchor('admin/products', 'Producten'); ?></div>
     <div class="option"><?php echo Html::anchor('admin/news', 'Nieuws berichten'); ?></div>
    </div>
    
    <?php echo $val->show_errors(); ?>
    <?php echo Form::open('admin/news/add'); ?>
    
    <div class="input text required">
        <?php echo Form::label('Titel', 'caption'); ?>
        <?php echo Form::input('caption', e($val->input('caption')), array('size' => '30')); ?>
    </div>
    
    ..........
    

    when removing the show_error line I get the error on e($val....) How come?
  • Anyone? Im not sure how the "Forge" method works.
  • forge() is the new factory()
  • In your controller change: $this->template->set('content', View::forge('admin/news_add'), false) to: $this->template->set('content', View::forge('admin/news_add')->set('val', $val, false), false)
  • thanks, I don't get any errors now... But the html does get stripped/encoded.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion